
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 14, values from 2350, 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:

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.

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

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.

their actually loaded on the root. could itt still be done without grabbing all root level vars?

Cant you just change the loading function to load the variables into an empty movieclip?

Or just bite the bullet.
ary = [D1_H0_CUM, D1_H0_SWE1, D1_HO_SWE2, // etc... ];
And next time, name your variables consistently to avoid this kind of nonsense.

Actually I can't control the vars, they come from a DB I don't have access to. Anyways I descided to do the math with php and have it add two more vars to the bunch( high and low) that are brought into Flash. Ya got ta give Flash a break now and then. :rolleyes:
Thanks guys!