Let’s say that I initially passed a parameter called ‘Testee’ to my preloader flash application via the HTML param tag. Now I need to pass this same parameter value from the preloader to the main flash application. Here is the code that receives the parameter from the the HTML:
var paramUserName:String; var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters; paramUserName = flashVars.Testee;
From flashVars, I get the Testee parameter and assign it to a variable called paramUserName.
In the preloader, after the loader has finished loading the main flash application, the event.complete calls my ‘done’ function:
_URLLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
In my ‘done’ function, after I add the _URLLoader, I call the dispatch event:
function done(e:Event):void
{
removeChild(percent);
removeChild(_bar_border);
removeChild (_bar_guts);
percent = null;
_bar_border = null;
_bar_guts = null;
addChild(_URLLoader);
e.target.content.dispatchEvent (new Event("change"));
}
In my main flash application, I add a listener for the dispatched event called as shown above, ‘change’:
addEventListener(Event.CHANGE, SetUserName);
I then receive the value of my passed parameter in my SetUserName function:
function SetUserName(event:Event)
{
var mTestee:String = event.target.parent.parent.paramUserName;
}
Again, the ‘paramUserName’ is the variable in my preloader flash application that was assigned the ‘Testee’ parameter from the HTML that called the preloader flash application.