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.

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6 - The options parameter was added in Flash<br />

Player 7. The ability to use different options parameters on multiple sort fields was added in<br />

Flash Player 8.<br />

Parameters<br />

fieldName:Object - A string that identifies a field to be used as the sort value, or an array in<br />

which the first element represents the primary sort field, the second represents the secondary<br />

sort field, <strong>and</strong> so on.<br />

options:Object [optional] - One or more numbers or names of defined constants, separated<br />

by the bitwise OR (|) operator, that change the sorting behavior. The following values are<br />

acceptable for the options parameter:<br />

■ Array.CASEINSENSITIVE or 1<br />

■ Array.DESCENDING or 2<br />

■ Array.UNIQUESORT or 4<br />

■ Array.RETURNINDEXEDARRAY or 8<br />

■ Array.NUMERIC or 16<br />

Code hinting is enabled if you use the string form of the flag (for example, DESCENDING)<br />

rather than the numeric form (2).<br />

Returns<br />

Array - The return value depends on whether you pass any parameters:<br />

■ If you specify a value of 4 or Array.UNIQUESORT for the options parameter, <strong>and</strong> two or<br />

more elements being sorted have identical sort fields, a value of 0 is returned <strong>and</strong> the array<br />

is not modified.<br />

■ If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter, an<br />

array is returned that reflects the results of the sort <strong>and</strong> the array is not modified.<br />

■ Otherwise, nothing is returned <strong>and</strong> the array is modified to reflect the sort order.<br />

Example<br />

The following example creates a new array <strong>and</strong> sorts it according to the name <strong>and</strong> city fields.<br />

The first sort uses name as the first sort value <strong>and</strong> city as the second. The second sort uses<br />

city as the first sort value <strong>and</strong> name as the second.<br />

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

rec_array.push({name: "john", city: "omaha", zip: 68144});<br />

rec_array.push({name: "john", city: "kansas city", zip: 72345});<br />

rec_array.push({name: "bob", city: "omaha", zip: 94010});<br />

for(i=0; i

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

Saved successfully!

Ooh no, something went wrong!