Naming variables

Variable names can only contain letters, numbers, and dollar signs ($). Do not begin variable names with numbers. Variables must be unique and they are case-sensitive in Flash Player 7 and later. For example, avoid the following variable names:

my/warthog = true;   // includes a slash 
my warthogs = true;  // includes a space 
my.warthogs = true; // includes a dot
5warthogs = 55;    // begins with a number

Use strict data typing with your variables whenever possible because it helps you in the following ways:

To add a data type to your variables, you must define the variable using the var keyword. In the following example, when creating a LoadVars object, you would use strict data typing:

var paramsLv:LoadVars = new LoadVars();

Strict data typing provides you with code completion, and ensures that the value of paramsLv contains a LoadVars object. It also ensures that the LoadVars object will not be used to store numeric or string data. Because strict typing relies on the var keyword, you cannot add strict data typing to global variables or properties within an object or array. For more information on strict typing variables, see About assigning data types and strict data typing.

NOTE

 

Strict data typing does not slow down a SWF file. Type checking occurs at compile time (when the SWF file is created), not at runtime.

Use the following guidelines when you name variables in your code:


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001094.html