1

次のようなPHPコードを使用してFlex4.5モジュール(SWFファイル)をロードしています。

$module = 'modules/'.$_GET['module'].'.swf';

if(!file_exists($module)) {

    $module = 'error.swf';

}

$size = filesize($module);
$contents = file_get_contents($module);

header('Content-Type: application/x-shockwave-flash');
header('Accept-Ranges: bytes');
header('Content-Length: '.$size);

echo $contents;

そしてそれは非常にうまく機能します。

ここで、追加のデータを取得して、モジュールにそのデータを1つのリクエストハンドラーでロードし、次のように入力します。

private function requestHandler(response:???):void {

    var data:Array = response as Array;

    mySparkModuleLoader.load("", data[0] as ByteArray);
    myController.load(data[1]);

}

私はAMFPHPでそれをやろうとしていましたが、ByteArrayが表示されないために壊れているか何かのようですが、残りのデータは問題ありません。

return array(
    'hello world!',
    new Amfphp_Core_Amf_Types_ByteArray(file_get_contents($module))
);

たぶん、http: //sun3.org/archives/107のようなマルチパート応答を作成して処理しますか?

どんなアイデアでも大歓迎です。

4

1 に答える 1

1

OMGは機能しています!

これが他の誰かに役立つことを願っています:

AMFPHP 2.0 RC1サービス:

<?php

class Services {

    public function getModule() {

        $path = dirname(__FILE__).'\..\..\Modules\Foo.swf';
        $ba = new Amfphp_Core_Amf_Types_ByteArray(file_get_contents($path));

        return array(
            $ba,
            array(
                'colors' => array(
                    'red',
                    'green',
                    'blue'
                ),
                'animals' => array(
                    'dog',
                    'cat'
                )
            )
        );

    }

}

サービス(Flex SDK 4.5を使用)ハンドラー:

private function resultHandler(event:ResultEvent):void {

    var response:Array = event.result as Array;

    moduleLoader.loadModule("http://some.random.url", response[0] as ByteArray);
    initialData = response[1] as Array;

}

以上です!

于 2011-10-07T10:25:33.650 に答える