03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - 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.

Example<br />

The following code explains how the length property is updated. The initial length is 0, <strong>and</strong><br />

then updated to 1, 2, <strong>and</strong> 10. If you assign a value to the length property that is shorter than<br />

the existing length, the array will be truncated:<br />

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

trace(my_array.length); // initial length is 0<br />

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

trace(my_array.length); // my_array.length is updated to 1<br />

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

trace(my_array.length); // my_array.length is updated to 2<br />

my_array[9] = "c";<br />

trace(my_array.length); // my_array.length is updated to 10<br />

trace(my_array);<br />

// displays:<br />

//<br />

a,b,undefined,undefined,undefined,undefined,undefined,undefined,undefine<br />

d,c<br />

// if the length property is now set to 5, the array will be truncated<br />

my_array.length = 5;<br />

trace(my_array.length); // my_array.length is updated to 5<br />

trace(my_array); // outputs: a,b,undefined,undefined,undefined<br />

NUMERIC (Array.NUMERIC property)<br />

public static NUMERIC : Number<br />

In the sorting methods, this constant specifies numeric (instead of character-string) sorting.<br />

Including it in the options parameter causes the sort() <strong>and</strong> sortOn() methods to sort<br />

numbers as numeric values, not as strings of numeric characters. Without the NUMERIC<br />

constant, sorting treats each array element as a character string <strong>and</strong> produces the results in<br />

Unicode order.<br />

For example, given the Array of values [2005, 7, 35], if the NUMERIC constant is not<br />

included in the options parameter, the sorted Array is [2005, 35, 7], but if the NUMERIC<br />

constant is included, the sorted Array is [7, 35, 2005].<br />

Note that this constant only applies to numbers in the array; it does not apply to strings that<br />

contain numeric data (such as ["23", "5"]).<br />

The value of this constant is 16.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 7<br />

See also<br />

sort (Array.sort method), sortOn (Array.sortOn method)<br />

258 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!