1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

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

By

Before you can load an external file from Flash, you'll need to create the file first. I prefer to use .txt (text) files for basics, and usually set up my variables in Notepad. For this example, I've created four variables and saved them in Notepad: typecolor, typetext, typestyle, and typesize, as we're going to use them to alter the text displayed by a Flash SWF. The format is pretty simple:
 typecolor=990000 
typetext=Now my text is loaded by variables. 
typestyle=Times New Roman 
typesize=30

The variable values are now defined much as we would in Flash, only without quotes around things like the font name. I also chose not to put the 0x in front of the hex value for the font color; that's just an old habit, as I like to keep it in plain HTML should I use the variable for certain other things, and use ActionScripting to append the 0x when I need it.

©2014 About.com. All rights reserved.