MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 264

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

var rec_array:Array = new Array();
rec_array.push({name: "john", city: "omaha", zip: 68144});
rec_array.push({name: "john", city: "kansas city", zip: 72345});
rec_array.push({name: "bob", city: "omaha", zip: 94010});
for(i=0; i<rec_array.length; i++){
trace(rec_array[i].name + ", " + rec_array[i].city);
}
// Results:
// john, omaha
// john, kansas city
// bob, omaha
rec_array.sortOn(["name", "city"]);
for(i=0; i<rec_array.length; i++){
trace(rec_array[i].name + ", " + rec_array[i].city);
}
// Results:
// bob, omaha
// john, kansas city
// john, omaha
rec_array.sortOn(["city", "name" ]);
for(i=0; i<rec_array.length; i++){
trace(rec_array[i].name + ", " + rec_array[i].city);
}
// Results:
// john, kansas city
// bob, omaha
// john, omaha
The following array of objects is used by subsequent examples that show how to use the
parameter:
options
var my_array:Array = new Array();
my_array.push({password: "Bob", age:29});
my_array.push({password: "abcd", age:3});
my_array.push({password: "barb", age:35});
my_array.push({password: "catchy", age:4});
Performing a default sort on the password field produces the following results:
my_array.sortOn("password");
// Bob
// abcd
// barb
// catchy
Performing a case-insensitive sort on the password field produces the following results:
my_array.sortOn("password", Array.CASEINSENSITIVE);
// abcd
// barb
// Bob
264
ActionScript classes

Advertisement

Table of Contents
loading

Table of Contents