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 don’t 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)
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...