3.
Select Control > Test Movie to test your ActionScript.
The first
trace()
array (
myArray
1,2,3
the
array, each of the array's values are overwritten and set to zero. The
myArray
subsequent
trace()
Because you pass the array by reference and not by value, you don't need to return the
updated contents of the array from within the
For more information on arrays, see
About variables and scope
A variable's scope refers to the area in which the variable is known (defined) and can be
referenced. The area in which the variable is known might be within a certain timeline or
inside a function, or it might be globally known throughout the entire application.For more
information about scope, see
Understanding variable scope is important when you develop Flash applications with
ActionScript. Scope indicates not only when and where you can refer to variables but also for
how long a particular variable exists in an application. When you define variables in the body
of a function, they cease to exist as soon as the specified function ends. If you try to refer to
objects in the wrong scope or to variables that have expired, you get errors in your Flash
documents, which lead to unexpected behavior or broken functionality.
There are three types of variable scopes in ActionScript:
Global variables
and functions are visible to every timeline and scope in your document.
Therefore, a global variable is defined in all areas of your code.
Timeline variables
Local variables
are available within the function body in which they are declared
(delineated by curly braces). Therefore, local variables are only defined in a part of
your code.
For guidelines on using scope and variables, see
page
123.
ActionScript 2.0 classes that you create support public, private, and static variable
scopes. For more information, see
"Controlling member access in your classes" on page
You cannot strict type global variables. For information and a workaround, see
variables" on page
97.
96
Data and Data Types
statement in this ActionScript displays the original contents of the
). After you call the
statement displays the new contents of the
"About arrays" on page
"About scope and targeting" on page
are available to any script on that timeline.
"About class members" on page 250
function and pass a reference to
zeroArray()
function.
zeroArray()
163.
Chapter 5, "About scope and targeting," on
273.
array (
myArray
0,0,0
123.
and
"Global
).
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?