1. Home
  2. Computing & Technology
  3. Animation

Using Variables from an External Source with Flash's loadVariables()

By Adrien-Luc Sanders, About.com

7 of 9

In order for loadVariables() to work properly, you have to specify the file name/location, the target clip/level, and (optionally) the method (GET or POST, not really applicable here as we're not sending data back and getURL is better for that).
onClipEvent(enterFrame){
loadVariables("variables.txt", this);
}

The file name must be enclosed in quotes; if the file containing your variables is in the same folder as your SWF file on your local drive or web server, then you can just put the name and extension. If not, you need to include the absolute or relative path to the location of the variables file.

The target can either be numeric to load the variables into a specific level on the stage, or can be the name/path of the target movie clip (I just use "this" to load it into the current clip).

Explore Animation
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Using Variables from an External Source with Flash's loadVariables()

©2009 About.com, a part of The New York Times Company.

All rights reserved.