User Guide
38 Chapter 1: ActionScript Basics
This code is equivalent to the following code, which is slightly easier to read:
flavor = getIceCreamFlavor();
if (flavor != "vanilla") {
trace ("Flavor was " + flavor + ", not vanilla.");
}
The following table lists the ActionScript assignment operators:
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.
Dot operator. 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"];
Operator Operation performed
=
Assignment
+=
Addition and assignment
-=
Subtraction and assignment
*=
Multiplication and assignment
%=
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