Moving From Flash AS2 to Flash AS3: FlashVars
Published by Angel on Tagged Actionscript 3.0, Moving From AS2 to AS3What is FlashVars?
FlashVars is Flash answer to Query String. It's a way to pass data or variables from html to a Flash movie. Variables passed via FlashVars will go into the _root level of the Flash movie.
Differences Between AS2 and AS3
The key difference between AS2 and AS3 is how to retrieve the FlashVars. The FlashVars are no longer available in the _root level of the movie. Instead, you must use the new LoaderInfo class object to access the FlashVars. The FlashVars is available in the parameters member of the LoaderInfo. This makes the AS3 solution much more dynamic and independent to each object that is created. See below for an example of both.
FlashVars in AS2
var myFlashVar:String; _root.createTextField("myTextField", 1, Stage.width/2 - 50, Stage.height/2 , 150, 40); myTextField.text = myFlashVar;
FlashVars in AS3
function loaderComplete(myEvent:Event) { this.flashVars=this.loaderInfo.parameters; this.flashVarsLoaded=true; // set a flag to indicate that the FlashVars is loaded this.useFlashVars(); }
I hope this post helped you understand the key difference between defining your FlashVars within AS2 and AS3. If your interested in learning more about FlashVars, check out the resources below as they will go deeper into the topic.
Resources on FlashVars:
- Understanding FlashVars within AS2
- Understanding FlashVars within AS3
- FlashVars in AS3
- What is LoaderInfo?
I would like to hear from you on how I can make the series of posts "Moving From Flash AS2 to Flash AS3" better. Looking forward to hearing from you!
Related Posts
- Moving from Flash AS2 to Flash AS3: Paths
- AFC Releases Free Embeddable FLV Player v.1.0
- Flash Stock of the Day: FLV Player With YouTube Support
- Flash Countdown Timer
- Updated: Free .PPT to Flash Converter Has Arrived




May 23rd, 2008 at 8:23 am
[...] it is very customizable allowing you to customize many properties via the query string/FlashVars. If you are looking for a sleek, customizable FLV player for your personal and YouTube [...]