Since I'm not trying this out in Flash, you may have to play around with the code a little bit to make sure I used the right syntax, but this should do it for you.
ps. You can add the numbers to the array in any way you want... in fact, you could just add them WITHOUT using variables.... just .push() the number onto the array instead of storing it in a variable.
var name1:Number = 10; var name2:Number = 33; var name3:Number = 21; var name4:Number = 100;
var myArray:Array = new Array(); myArray.push(name1); myArray.push(name2); myArray.push(name3); myArray.push(name4);
myArray.sort(Array.NUMERIC); //Array.NUMERIC is important because arrays, by default, sort as if all of their values were strings. myArray.reverse();
trace(myArray); //output: 100;
Basically, you're just putting the numbers in an array and sorting them... that puts them in Ascending order, so you'd have to find the LAST number. Instead, you just reverse the array and the largest number will always be at .
Last edited by Taidaishar; 10-10-2008 at 03:40 PM.