EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 246

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
246 Chapter 12: ActionScript Dictionary
Usage 1 and 2: The following example creates an array called employee_array and uses the
trace() action to send the elements to the Output panel. In the fourth line, an element in the
array is changed and the fifth line sends the newly modified array to the Output panel:
employee_array = ["Barbara", "George", "Mary"];
trace(employee_array);
// Barbara, George, Mary
employee_array[2]="Sam";
trace(employee_array);
// Barbara, George, Sam
Usage 3: In the following example, the expression inside the brackets ("piece" + i) is evaluated
and the result is used as the name of the variable to be retrieved from the
my_mc movie clip. In this
example, the variable
i must live on the same Timeline as the button. If the variable i is
equal to 5, for example, the value of the variable
piece5 in the my_mc movie clip will be displayed
in the Output panel:
on(release){
x = my_mc["piece"+i];
trace(x);
}
Usage 3: In the following code, the expression inside the brackets is evaluated and the result is
used as the name of the variable to be retrieved from movie clip
name_mc:
name_mc["A" + i];
If you are familiar with the Flash 4 ActionScript slash syntax, you can use the eval function to
accomplish the same result:
eval("name.A" & i);
Usage 3: You can also use the array access operator on the left side of an assignment statement to
dynamically set instance, variable, and object names:
name[index] = "Gary";
See also
Array class, Object class, eval()
^ (bitwise XOR)
Availability
Flash Player 5.
Usage
expression1 ^ expression2
Parameters
expression1,expression2
A number.
Returns
None.

Table of Contents

Related product manuals