# Highest And Lowest Vars

• 03-08-2005, 04:17 AM
FlashGod.com
Highest And Lowest Vars
I have about 200 variables that create a graph, and the variables come from different categories with different ranges of values. (ex: values ranging from 1-4, values from 23-50, etc.)

What I need to do is get the highest value and the lowest of all the vars so I know the range to dynamically set the graph at.

I know how to do it on vars like this ( var1=5, var2=3) but he var names are very different. What I really want is to dump all of the vars in an array, then get a Math.findMax, and a Math.findMin, checking them at a ++ rate.

Lets see what you Flash kitters can do.:cool:
• 03-08-2005, 06:06 AM
mkantor
Try something like this:
Code:

``` function getMax( a : Array) : Number {     var m : Number = a[0];     for(var i in a) {         if(a[i] > m) m = a[i];     }     return m; }```
This uses the for..in iteration, which ought to be the fastest available.
• 03-08-2005, 02:16 PM
FlashGod.com
How do i get all of my vars (that Ive loaded from txt files), into that array?

If this helps, here are a few of the vars (of 196) :

D1_H0_CUM=3
D1_H0_SWE1=2.5
D1_H0_SWE2=3.5
D1_H6_SWE3=1.5
D1_H6_SWE4=1.9
D2_H0_SWE5=3.8
D2_H0_SWE6=2.7
D3_H0_SEC1=7.4

Thanks
• 03-08-2005, 03:02 PM
Scimmer
I assume you loaded them into an empty movieclip mc. Then you can do something like this:

var aVals = new Array ();
for (var i in mc)
aVals.push (mc [i]);

This isnt the fastest way but the easiest one.
• 03-08-2005, 05:23 PM
FlashGod.com
their actually loaded on the root. could itt still be done without grabbing all root level vars?
• 03-08-2005, 06:53 PM
Scimmer