Usage 1 and 2: The following example creates an array called
action to send the elements to the Output panel. In the fourth line, an element in the
trace()
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 (
and the result is used as the name of the variable to be retrieved from the
example, the variable
equal to 5, for example, the value of the variable
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["A" + i];
If you are familiar with the Flash 4 ActionScript slash syntax, you can use the
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
^ (bitwise XOR)
Availability
Flash Player 5.
Usage
expression1 ^ expression2
Parameters
expression1,expression2
Returns
None.
246
Chapter 12: ActionScript Dictionary
must live on the same Timeline as the button. If the variable
i
class,
eval()
A number.
employee_array
in the
movie clip will be displayed
piece5
my_mc
name_mc
and uses the
is evaluated
"piece" + i)
movie clip. In this
my_mc
is
i
:
function to
eval
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?