I forget you can use "Array.NUMERIC" when you want to sort an array :D

So you must to put:
aMovieClipsSorted.sort(Array.NUMERIC);

Erik Porroa V. escribió:
Ey Stephen, you can do something like this:
//Create a function that return the sorted numbers
function sortByNumber(a, b) {
 return (a > b);
}
//I guess this array will be generated dinamically
var aMovieClips:Array = new Array("mcClip0", "mcClip1", "mcClip2");

//A new array where will go the scaled numbers
var aMovieClipsSorted:Array = new Array();

//A loop that put all the xScales in the new Array
for(var j:Number = 0; j<aMovieClips.length; j++){
   aMovieClipsSorted.push(Number(Math.round(_root["mcClip"+j]._xscale)));
}
//Testing
trace(aMovieClipsSorted)
aMovieClipsSorted.sort(sortByNumber);
trace(aMovieClipsSorted)

And that's all, I put a Math.round method that return a rounded number (you can change it for his original xScale)

Cheers!

Erik
http://www.porroa.com/erik
Hello All. Here is what I have and what I'm trying to do:
I have an array that contains 3 objects (which are all movie clips), like so: var myArray:Array = ["mcClip1", "mcClip2", "mcClip3"]; I want to sort this array according to the _xscale of these clips. Does anyone know how I can do this. This is my line of thought, which I know is wrong, but might give more insight: myArray._xscale.sort(Array.DESCENDING); Please advise if you can. Thanks,
Stephen.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to