【发布时间】:2009-06-15 20:09:01
【问题描述】:
我正在开发一个 AIR 应用程序,该应用程序需要加载、运行和访问从网上提取的 swf 上的方法。过去使用模块效果很好,但由于设计限制,无法用于此应用程序。您可以在下面看到我加载 ImageTest.swf 然后在其上调用函数 Bleh() 的代码。
private var l:Loader = new Loader();
private var ctx:LoaderContext;
private function onInit():void
{
l.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onLoadError);
l.load(new URLRequest("ImageTest.swf"));
}
private function onLoadError(event:IOErrorEvent):void
{
}
private function onLoadComplete(event:Event):void
{
ui.addChild(event.target.content);
SystemManager(event.target.content).addEventListener(FlexEvent.APPLICATION_COMPLETE, swfAppComplete);
}
private function swfAppComplete(event:FlexEvent):void
{
var sys:SystemManager = SystemManager(event.currentTarget);
var app:Object = sys.application;
app.Bleh();
}
当 swf 是 AIR 应用程序的本地文件时,这可以正常工作,但是当 ImageTest.swf 在服务器上关闭时,它可以正常加载,但我收到强制运行时错误(TypeError: Error #1034: Type Coercion failed: cannot将 _Engine_mx_managers_SystemManager@7c36281 转换为 mx.managers.SystemManager) 在该行:
SystemManager(event.target.content).addEventListener(FlexEvent.APPLICATION_COMPLETE, swfAppComplete);
我认为该错误可能与安全沙盒问题有关,但我不确定。提前致谢!
【问题讨论】:
标签: apache-flex actionscript-3