加载由mxml生成的swf,并访问内部方法

来源:互联网 发布:运营商云计算 编辑:程序博客网 时间:2024/06/01 17:14

利用Flex的MXML中的<s:SWFLoader source ="【路劲】" init=“【当swf可访问属性方法时的时候调用,这里用init(event)】”>

protected function  init(event:Event):void {event.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE,applicationCompleteHandler);}

然后在applicationCompleteHandler中才可以调用加载进来的swf中的方法,才能保证swf完全加载完毕,并且可以访问。

protected function applicationCompleteHandler(event:FlexEvent):void{var sysMgr:SystemManager = swfLoad.content as SystemManager;sysMgr.application["setURL"]("25",1,1,"10")}

这里通过["方法名"].(相关参数)就可以访问到swf中的相关方法。

如果用as语言添加SWFLoader,则为

swfLoader = new SWFLoader();

swfLoader.addEventListener(Event.INIT,init);

swfLoader.source = "AAACeshi.swf";

addElement(swfLoader) 【需要加这个添加到舞台才会显示出来】

调用swf中的方法用 swf["方法名"](相关参数) 调用相关属性 swf["属性名"]

0 0
原创粉丝点击