我正在使用这样的 PHP 代码加载 Flex 4.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;
它工作得很好。
现在我想在一个请求处理程序中获取一些额外的数据来加载和填充模块,例如:
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这样的多部分响应并处理它?
任何想法都会受到欢迎。