![MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual Download Page 49](http://html1.mh-extra.com/html/macromedia/flash-mx-2004-actionscript/flash-mx-2004-actionscript_reference-manual_3378897049.webp)
Using operators to manipulate values in expressions
49
Dot and array access operators
You can use the dot operator (
.
) and the array access operator (
[]
) to access built-in or custom
ActionScript object properties, including those of a movie clip.
The dot operator uses the name of an object on its left side and the name of a property or variable
on its right side. The property or variable name can’t be a string or a variable that evaluates to a
string; it must be an identifier. The following examples use the dot operator:
year.month = "June";
year.month.day = 9;
The dot operator and the array access operator perform the same role, but the dot operator takes
an identifier as its property, whereas the array access operator evaluates its contents to a name and
then accesses the value of that named property. For example, the following expressions access the
same variable
velocity
in the movie clip
rocket
:
rocket.velocity;
rocket["velocity"];
You can use the array access operator to dynamically set and retrieve instance names and variables.
For example, in the following code, the expression inside the
[]
operator is evaluated, and the
result of the evaluation is used as the name of the variable to be retrieved from movie clip
name
:
name["mc" + i]
You can also use the
eval()
function, as shown here:
eval("mc" + i)
The array access operator can also be used on the left side of an assignment statement. This allows
you to dynamically set instance, variable, and object names, as shown in the following example:
name[index] = "Gary";
%=
Modulo and assignment
/=
Division and assignment
<<=
Bitwise shift left and assignment
>>=
Bitwise shift right and assignment
>>>=
Shift right zero fill and assignment
^=
Bitwise XOR and assignment
|=
Bitwise OR and assignment
&=
Bitwise AND and assignment
Operator
Operation performed
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...