It's a good idea to assign a value to a variable the first time you declare the variable. Assigning
an initial value is called initializing the variable, and it's often done on Frame 1 of the
Timeline or from within a class that loads when the SWF file begins to play. There are
different kinds of variables, which are affected by scope. For more information on different
kinds of variables and scope, see
Initializing a variable helps you track and compare the variable's value as the SWF file
plays.
Flash Player 7 and later evaluate uninitialized variables differently than Flash Player 6
and earlier. If you have written scripts for Flash Player 6 and plan to write or port scripts
for Flash Player 7 or later, you should be understand these differences to avoid
unexpected behavior.
Variables can hold different types of data; for more information, see
on page
72. The type of data that a variable contains affects how the variable's value changes
when you assign that value in a script.
Typical types of information that you can store in a variable include a URL (String type), a
user's name (String type), the result of a mathematical operation (Number type), the number
of times an event occurred (Number type), or whether a user has clicked a particular button
(Boolean type). Each SWF file and object instance (such as a movie clip) has a set of variables,
with each variable having a value independent of variables in other SWF files or movie clips.
To view the value of a variable, use the
panel. Then, the value displays in the Output panel when you test the SWF file in the test
environment. For example,
to the Output panel in the test environment. You can also check and set the
hoursWorked
variable values in the Debugger in the test environment.
For more information on variables, see the following topics:
"About declaring variables" on page 88
"About assigning values" on page 88
"About naming variables" on page 91
"Using variables in an application" on page 92
"About variables and scope" on page 96
"About default values" on page 88
"About operators and variables" on page 90
"About loading variables" on page 100
"Using variables in a project" on page 106
"About variables and scope" on page
statement to send the value to the Output
trace()
trace(hoursWorked)
96.
"About data types"
sends the value of the variable
About variables
87
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?