FlashVars are a technique for passing data to Flash in the form of name/value pairs. These are passed through the object tag of the web page, either as a parameter or as GET variables appended to the swf filename. The following examples illustrate these different techniques:

Note that in both these examples the variables are declared twice, once in a param tag and once in the embed tag. This is because different browsers use different parts of the object tag. Internet Explorer reads the object and param tags, whilst Netscape compatible browsers read the embed tag.

Using these variables in your actionscript code is done slightly differently depending on the version of actionscript you are using. In AS1 and AS2, using FlashVars is very simple. The variables are all made available within the root scope of your movie, and so are accessed like this:

trace(_root.name1);
//outputs: value1

or, if you prefer:

trace(_level0.name1);
//outputs: value1

In AS3, things are done slightly differently. The FlashVars are now stored as part of the loaderInfo object, and are accessed like this:

Replies To: Using FlashVars in AS2 and AS3

It has come to my attention that not all AS3 classes can access root, and hence the flashVars. The way I'm getting around this right now is to access the loaderInfo object from the class that is directly associated with my document, and put them as statics into a singleton that can be accessed from any class in the application.

To further clarify the above, "root" is a property of DisplayObject and it's ancestors, but it's value is not set until the object has been added to the stage. Solutions are to either store the loaderInfo parameters object earlier in the application flow, or use a reference to an object that is currently on the stage.