Operators
121
var my_array:Array = new Array();
my_array[0] = 15;
my_array[1] = "Hello";
my_array[2] = true;
You can use brackets ([]) to add a fourth element, as shown in the following example:
my_array[3] = "George";
You can use brackets ([]) to access an element in a multidimensional array. The first set of
brackets identifies the element in the original array, and the second set identifies the element
in the nested array. The following lines of code send the number 6 to the Output panel.
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
trace(ticTacToe[1][2]);// output: 6
Usage 3: You can use the array access ([]) operator instead of the
eval()
function to
dynamically set and retrieve values for movie clip names or any property of an object. The
following line of code sends the number 6 to the Output panel.
name["mc" + i] = "left_corner";
Availability:
ActionScript 1.0; Flash Lite 2.0
Operands
myArray :
Object
-
myArray
The name of an array.
a0, a1,...aN :
Object
-
a0,a1,...aN
Elements in an array; any native type or object
instance, including nested arrays.
i :
Number
-
i
An integer index greater than or equal to 0.
myObject :
Object
-
myObject
The name of an object.
propertyName :
String
-
propertyName
A string that names a property of the object.
Returns
Object
-
Usage 1: A reference to an array.
Usage 2: A value from the array; either a native type or an object instance (including an Array
instance).
Usage 3: A property from the object; either a native type or an object instance (including an
Array instance).
Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...