EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 275

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Array class 275
Description
Constructor; lets you create an array. You can use the constructor to create different types of
arrays: an empty array, an array with a specific length but whose elements have no values, or an
array whose elements have specific values.
Usage 1: If you dont specify any parameters, an array with a length of 0 is created.
Usage 2: If you specify only a length, an array is created with
length number of elements with
no values.
Usage 3: If you use the
element parameters to specify values, an array is created with
specific values.
Example
Usage 1: The following example creates a new Array object with an initial length of 0.
my_array = new Array();
trace(my_array.length); // returns 0
Usage 2: The following example creates a new Array object with an initial length of 4.
my_array = new Array(4);
trace(my_array.length); // returns 4
Usage 3: The following example creates the new Array object go_gos_array, with an initial
length of 5.
go_gos_array = new Array("Belinda", "Gina", "Kathy", "Charlotte", "Jane");
trace(my_array.length); // returns 5
trace(go_gos_array.join(", ")); // displays elements
The initial elements of the go_gos array are identified as follows:
go_gos_array[0] = "Belinda";
go_gos_array[1] = "Gina";
go_gos_array[2] = "Kathy";
go_gos_array[3] = "Charlotte";
go_gos_array[4] = "Jane";
The following code adds a sixth element to the go_gos_array array and changes the second
element:
go_gos_array[5] = "Donna";
go_gos_array[1] = "Nina"
trace(go_gos_array.join(" + "));
See also
Array.length
, [] (array access)

Table of Contents

Related product manuals