03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The Array class should not be used to create associative arrays, which are different data<br />

structures that contain named elements instead of numbered elements. You should use the<br />

Object class to create associative arrays (also called hashes). Although ActionScript permits you<br />

to create associative arrays using the Array class, you can not use any of the Array class<br />

methods or properties. At its core, an associative array is an instance of the Object class, <strong>and</strong><br />

each key-value pair is represented by a property <strong>and</strong> its value. Another reason to declare an<br />

associative array as a type Object is that you can then use an object literal to populate your<br />

associative array (but only at the time you declare it). The following example creates an<br />

associative array using an object literal, accesses items using both the dot operator <strong>and</strong> the<br />

array access operator, <strong>and</strong> then adds a new key-value pair by creating a new property:<br />

var myAssocArray:Object = {fname:"John", lname:"Public"};<br />

trace(myAssocArray.fname); // Output: John<br />

trace(myAssocArray["lname"]); // Output: Public<br />

myAssocArray.initial = "Q";<br />

trace(myAssocArray.initial); // Output: Q<br />

Example<br />

In the following example, my_array contains four months of the year:<br />

var my_array:Array = new Array();<br />

my_array[0] = "January";<br />

my_array[1] = "February";<br />

my_array[2] = "March";<br />

my_array[3] = "April";<br />

Property summary<br />

Modifiers Property Description<br />

static CASEINSENSITIVE:Numb<br />

er<br />

Represents case-insensitive sorting.<br />

static DESCENDING:Number Represents a descending sort order.<br />

232 ActionScript classes<br />

length:Number A non-negative integer specifying the number of<br />

elements in the array.<br />

static NUMERIC:Number Represents numeric sorting instead of stringbased<br />

sorting.<br />

static RETURNINDEXEDARRAY:N<br />

umber<br />

Represents the option to return an indexed array<br />

as a result of calling the sort() or sortOn()<br />

method.<br />

static UNIQUESORT:Number Represents the unique sorting requirement.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!