我的嵌入式的SWF文件在我的应用程序
I embedded a swf file in my application
<mx:SWFLoader source="@Embed(source='mod/VideoModule.swf')" width="50" height="50" id="loader" creationComplete="initLoader()" />
与Flex文档,我想通过创建的SystemManager我加载的SWF进行交互的帮助
now with the help of the flex documentation I wanted to interact with my loaded swf by creating a SystemManager
[Bindable]
public var loadedSM:SystemManager;
private function initLoader() : void {
trace(loader.content);
loadedSM = SystemManager(loader.content);
var b: Button = loadedSM.application["button1"] as Button;
b.addEventListener(MouseEvent.CLICK, test);
}
但启动错误#1034时,说Main__embed_mxml_mod_VideoModule_swf_856293516 @ 33f53c1不能转换成mx.managers.SystemManager应用程序时
But when starting the application the error#1034 occurs and says that Main__embed_mxml_mod_VideoModule_swf_856293516@33f53c1 could not be converted into mx.managers.SystemManager
什么想法?
在此先感谢
塞巴斯蒂安
所以,首先我会使用SWF加载广告的完整的事件创建SWF加载时creationComplete事件将触发,而不是与它的内容都加载。
So firstly i'd use the complete event of SWF loader ad the creationComplete event will fire when swf loader is created, not with it's contents have loaded.
<mx:SWFLoader source="@Embed(source='mod/VideoModule.swf')" width="50" height="50" id="loader" complete="loaderCompleteHandler(event)" />
后来我也将通过事件发生时的FlexEvent说法。这一事件,您可以访问的SWFLoader的实例。随后的SWFLoader有一个属性叫做内容,这将给你访问加载的SWF。如果SWF然后公开了一个名为Button1,你可以做类似属性:
Then i would also pass the FlexEvent argument when the event fires. That event gives you access to the instance of SWFLoader. SwfLoader then has a property called content which will give you access to the loaded swf. If the swf then exposes a property named button1 you could do something like:
private function loaderCompleteHandler(event : FlexEvent) : void
{
var swfLaoder : SWFLoader = SWFLoader(event.target);
swfLaoder.content["button1"].addEventListener(MouseEvent.CLICK, test);
}