User Guide
120 ActionScript language elements
Example
Usage 1: This example uses the+= operator with a string expression and sends "My name is
Gilbert" to the Output panel.
var x1:String = "My name is ";
x1 += "Gilbert";
trace(x1); // output: My name is Gilbert
Usage 2: The following example shows a numeric use of the addition assignment (+=)
operator:
var x:Number = 5;
var y:Number = 10;
x += y;
trace(x); // output: 15
See also
+ addition operator
[] array access operator
myArray = [ a0, a1,...aN ]
myArray[ i ] = value
myObject [ propertyName ]
Initializes a new array or multidimensional array with the specified elements (a0, and so on),
or accesses elements in an array. The array access operator lets you dynamically set and retrieve
instance, variable, and object names. It also lets you access object properties.
Usage 1: An array is an object whose properties are called elements, which are each identified
by a number called an index. When you create an array, you surround the elements with the
array access ([]) operator (or brackets). An array can contain elements of various types. For
example, the following array, called
employee, has three elements; the first is a number and
the second two are strings (inside quotation marks):
var employee:Array = [15, "Barbara", "Jay"];
You can nest brackets to simulate multidimensional arrays. You can nest arrays up to 256
levels deep. The following code creates an array called
ticTacToe with three elements; each
element is also an array with three elements:
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; // Select Debug >
List Variables in test mode
// to see a list of the array elements.
Usage 2: Surround the index of each element with brackets ([]) to access it directly; you can
add a new element to an array, or you can change or retrieve the value of an existing element.
The first index in an array is always 0, as shown in the following example: