Adobe Flash CS5.5 and AS3 – How to pass a variable from one flash application to another

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 (_bar_guts);
percent = null;
_bar_border = null;
_bar_guts = null;

addChild(_URLLoader); (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 =;

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.

Leave a Reply

Your email address will not be published. Required fields are marked *