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.
Asked
Active
Viewed 8,229 times
1 Answers
10
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 );
}

spender
- 117,338
- 33
- 229
- 351
-
i spent 6 hours loading it wrong based on all the other incorrect methods of a loading an remote swf. you sir just saved me 10 years off my life. – Ryan Mills Dec 20 '11 at 19:45
-
i don't know why but for my case, the 'event.target.content' is always instance of 'mx_managers_SystemManager' – jondinham Sep 17 '12 at 10:39
-
It would be useful to see what the code for the child swf too? – Christopher Grigg Jan 11 '13 at 11:27