array = array.sort();

smallest = array[0];

 

Jake Churchill
CF Webtools
11204 Davenport, Ste. 100
Omaha, NE  68154
 <http://www.cfwebtools.com> http://www.cfwebtools.com
402-408-3733 x103

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Paul Andrews
Sent: Thursday, April 16, 2009 11:44 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] How can I receive the smallest value within an
Array?

 






Just for the future, most people would do this:

 

for ( var i:int =1; i<array.length; i++)

 

----- Original Message ----- 

From: - - <mailto:sailorse...@yahoo.com>  

To: flexcoders@yahoogroups.com 

Sent: Thursday, April 16, 2009 5:06 PM

Subject: Re: [flexcoders] How can I receive the smallest value within an
Array?

 

I got it:

 

public function maxValue(array:Array):int

{

var value:int = array[0];

var i:int = new int(0);

for (i; i<array.length; i++) 

{ 

if (array[i]>value)

{ 

value = array[i]; 

} 

} 

return value;

}

public function minValue(array:Array):int

{

var value:int = array[0];

var i:int = new int(0);

for (i; i<array.length; i++) 

{ 

if (array[i]<value)

{ 

value = array[i]; 

} 

} 

return value;

}

 

 


  _____  


From: sailorsea21 <sailorse...@yahoo.com>
To: flexcoders@yahoogroups.com
Sent: Thursday, April 16, 2009 11:56:01 AM
Subject: [flexcoders] How can I receive the smallest value within an Array?

Hi everyone, if I have an array as

var boxSize:Array = new Array(25, 45, 32, 70, 50, 46, 80, 10);

Is there a function that will return me the smallest value within that
array?

Thanks.

-David

 



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.287 / Virus Database: 270.11.58/2062 - Release Date: 04/16/09
08:12:00

Reply via email to