我有一个swf(child.swf),我想加载到另一个(parent.swf)。我希望通过我正在使用的加载器将参数传递给child.swf。 请注意,我没有试图通过的FlashVars parent.swf已经有,而是我试图通过自定义参数加载一个瑞士法郎通过另一个瑞士法郎。
解决方案在子swf中,写一个函数(下面的代码中的init)来接收任何参数。当Loader发出Event.COMPLETE信号时,如下调用parent.swf函数: $ $ $ $ $ $ $ $ $ $ var request:URLRequest = new URLRequest child.swf); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadHandler); loader.load(request); 函数loadHandler(event:Event):void { var childSwf:Object = event.target.content; childSwf.init(PARAMS); }
I have a swf (child.swf) that I wish to load into another (parent.swf). I wish to pass a parameter to child.swf through the loader I am using. Note that I am not trying to pass FlashVars that parent.swf already has, but rather I am trying to simply load a swf through another swf with custom arguments.
解决方案In the child swf, write a function (init in the code below) to receive any params. When the Loader signals Event.COMPLETE, call the function from parent.swf as follows:
var request:URLRequest = new URLRequest("child.swf"); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler); loader.load(request); function loadHandler(event:Event):void { var childSwf:Object = event.target.content; childSwf.init( PARAMS ); }
更多推荐
通过Loader将参数传递给swf
发布评论