inicio mail me! sindicaci;ón

t-roy.net*

blog by designer troy ginbey

Array Methods in AS3.0

I’ve been using Array for a while now – but don’t frequently use all of it’s methods… so I’m going to go through the ones I don’t use a lot….

Array.sort();

var beers:Array = ["Fosters", "Alpha", "VB", "asahi"];
beers.sort(); // default sort
trace(beers); // output: Alpha,Fosters,VB,asahi

beers.sort(Array.CASEINSENSITIVE);
trace(beers); // output: Alpha,asahi,Fosters,VB

beers.sort(Array.DESCENDING);
trace(beers); // output: asahi,VB,Fosters,Alpha

beers.sort(Array.DESCENDING | Array.CASEINSENSITIVE);
trace(beers); // output: VB,Fosters,asahi,Alpha

2 Comments »

  Svilen Georgiev wrote @ February 6th, 2009 at 9:49 pm

I think you have a mistake in your output string after the sort() method. Suddenly beers array is sorted but having other values.

  T-roy wrote @ June 13th, 2009 at 9:48 pm

Thanks Svilen! – fixed

Your comment

HTML-Tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>