Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-12-2006, 03:47 PM   #1
rickid
Registered User
 
Join Date: Feb 2005
Posts: 77
Default How to find the highest number!?

Hi,

Does anyone know a command to find the higher number from a list of numbers?

Thanks,
Rik
rickid is offline   Reply With Quote
Old 08-12-2006, 03:51 PM   #2
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

Math.max() will find the highest of 2. If you have more than that, you'll have to do some looping and some if checks to see which is higher. Some examples can be found here:
http://proto.layer51.com
__________________
(6)
senocular is offline   Reply With Quote
Old 08-12-2006, 03:55 PM   #3
rickid
Registered User
 
Join Date: Feb 2005
Posts: 77
Default

Thanks Senocular,

It's already looping over a wddx (xml) file. The following code returns all the numbers:

Code:
for(var a in wddxObj){
var number:String=wddxObj[a]['NUMBER']
trace(number)
}
I'll try Max.max() with that.
rickid is offline   Reply With Quote
Old 08-12-2006, 04:18 PM   #4
mooska
fl.mooska._title
 
mooska's Avatar
 
Join Date: Jun 2006
Location: lodz
Posts: 1,211
Send a message via ICQ to mooska Send a message via Skype™ to mooska
Default

Maybe try with Array.sort() ?
__________________
pebkac - problem exists between keyboard and chair

Have something to code ?

asql
mooska is offline   Reply With Quote
Old 08-12-2006, 04:49 PM   #5
Sunny13
Senior Member
 
Join Date: Jul 2005
Location: India
Posts: 1,029
Default

To use Array.sort() you need to use an additional parameter also because it considers the data as string only even if it is numeric.... so try this....
Code:
var Arr = ["21", "22", "5", "34", "87", "56"];
Arr.sort();
trace("Not Desired: "+Arr);
var Arr = ["21", "22", "5", "34", "87", "56"];
Arr.sort(Array.NUMERIC);
trace("Not Desired: "+Arr);
var Arr = [21, 22, 5, 34, 87, 7, 0.7, 56,-9];
Arr.sort(Array.NUMERIC);
trace(".......................");
trace("Desired : "+Arr);
__________________
SKS

The Tutorial Hub
Sunny13 is offline   Reply With Quote
Old 08-12-2006, 05:47 PM   #6
jharmon
Registered User
 
Join Date: Nov 2005
Posts: 56
Default

Code:
var highest:Number = 0;

for(var a in wddxObj){
var number:String=wddxObj[a]['NUMBER']
     if (number > highest){
          highest = number;
     }
}
trace(highest);
jharmon is offline   Reply With Quote
Old 08-12-2006, 06:16 PM   #7
rickid
Registered User
 
Join Date: Feb 2005
Posts: 77
Default

Thanks will try that!
rickid is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Paint by number blahblah ActionScript 2.0 1 06-13-2006 04:30 AM
Trying to get number of XML nodes with name x and number with name y sfdesigner ActionScript 2.0 1 06-13-2005 09:03 AM
Convert String to a Number macspud ActionScript 1.0 (and below) 1 01-06-2005 06:36 PM


All times are GMT. The time now is 01:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.