Loading Variables

   

Loading Variables

One of the key factors and appeals of Flash is that you don't always have to initialize your variables within the Flash document. Flash gives you the power to read variables from external sources as well, such as a text file, a database query, a middleware script (CGI, PHP, JSP, ASP, ColdFusion, and so on), and HTML tags. The ability to read from external sources makes it easier to update your Flash movie because, instead of opening Flash to edit your document and publishing it again, you can simply update the external file. For example, let's say you have content within a Flash document that needs to be updated on a daily basis. You could set that up to read from an external text file. This becomes extremely handy when you create a Web site or application and want to update some information within. You don't need to know Flash in order to update the information; all you need to know is how to use NotePad (Windows) or SimpleText (Macintosh).

TIP

When creating your external text file, write it without any line breaks or spaces and try to use only an ampersand instead of the word 'and.' Flash will understand an external text file better this way.


To load an external file, you must first set it up to be loaded. Be sure that the external file is located in the same directory as your final published movie. Select a keyframe at which point you want this variable to be loaded. In the Actions panel's toolbox, select Actions, Browser/Network, loadVariablesNum . In Normal mode, three parameters must be defined (see Figure 11.1).

Figure 11.1. loadVariablesNum requires three parameters to be defined.

graphics/11fig01.gif

NOTE

Flash loads the variables from your external file to the root Timeline or level 0. These variables are now scoped to _root.


If you would like more control over your externally loaded data, use the LoadVars object, as opposed to the loadVariables command. The LoadVars object has its own properties, methods , and events to handle and manipulate incoming and outgoing data. All that the LoadVars object requires is a name and value format.


   
Top


Certified Macromedia Flash MX Designer Study Guide
Certified Macromedia Flash MX Designer Study Guide
ISBN: 0321126955
EAN: 2147483647
Year: 2001
Pages: 142

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net