[] Array Access Operator - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

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 (
, and so on),
a0
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
, has three elements; the first is a number and
employee
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
with three elements; each
ticTacToe
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.
134
ActionScript language elements

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents