Determining the maximum value in an array without looping

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”; creationComplete=”init()”>
import mx.collections.Sort;
import mx.collections.ArrayCollection;
private var myArray:Array = [2,3,3,4,2,2,5,6,7,2];
private var ac:ArrayCollection = new ArrayCollection(myArray);
[Bindable] private var maxValue:int = 0;
private function init():void
ac.sort = new Sort();
maxValue = int(ac.getItemAt(ac.length-1));
<mx:Label text=”Max: {maxValue}”/>

~ by mjcprasad2000 on January 29, 2009.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: