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.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...