Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing parameters to a swf via Loader

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.

like image 478
Jeff Winkworth Avatar asked Dec 31 '22 06:12

Jeff Winkworth


1 Answers

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 );
}
like image 147
spender Avatar answered Jan 08 '23 10:01

spender