To test the value of a variable, use the
example,
trace(hoursWorked)
in test mode. You can also check and set the variable values in the Debugger in test mode. For
more information, see
variables" on page
Naming a variable
A variable's name must follow these rules:
•
It must be an identifier (see
•
It cannot be a keyword or an ActionScript literal such as
•
It must be unique within its scope (see
Also, you should not use any element in the ActionScript language as a variable name; doing so
can cause syntax errors or unexpected results. For example, if you name a variable
then try to create a String object using
hello_str = new String();
trace(hello_str.length); // returns 0
String = "hello"; // Giving a variable the same name as a built-in class
hello_str = new String();
trace(hello_str.length); // returns undefined
The ActionScript editor supports code hints for built-in classes and for variables that are based on
these classes. If you want Flash to provide code hints for a particular object type that is assigned to
a variable, you can strictly type the variable or name the variable using a specific suffix.
For example, suppose you type the following code:
var members:Array = new Array();
members.
As soon as you type the period (
Array objects. For more information, see
Scoping and declaring variables
A variable's scope refers to the area in which the variable is known and can be referenced. There are
three types of variable scope in ActionScript:
•
Local variables
curly braces).
•
Timeline variables
•
Global variables
Note: ActionScript 2.0 classes that you create support public, private, and static variable scopes. For
more information, see
on page
165.
trace()
sends the value of the variable
"Using the trace statement" on page 79
72.
"Terminology" on page
new String()
), Flash displays a list of methods and properties available for
.
are available within the function body in which they are declared (delineated by
are available to any script on that Timeline.
and functions are visible to every Timeline and scope in your document.
"Controlling member access" on page 164
action to send the value to the Output panel. For
hoursWorked
26).
true
"Scoping and declaring variables" on page
, the new object is undefined.
"Writing code that triggers code hints" on page
to the Output panel
and
"Displaying and modifying
,
,
, or
false
null
undefined
String
and
"Creating class members"
About variables
.
41).
and
61.
41
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?