-
random variables
hiya!
i was wondering is its possible to do random variables?
like, if a had 2 variables, min = 10 and max = 15,
then what i wanna do is make an event that
randomly chooses a value between the numerical values
of min and max, (10 - 15)
any ideas?
thnx a bunch!!:D
-
ran=1;
ran=math.round(math.random()*5+10);
min=ran;
-
hehe, i little explaination would be appreciated.:)
anyhow, tank you a bunch!:D
-
The code will make a random value between 10 and 15 for the variable min
If you want random value from the difference between min and max .........and add that to the min value......
mini=101;
maxi=152;
ran_value=maxi-mini;
ran=1;
end_value=math.round(math.random()*ran_value+mini) ;
trace(end_value);
This will get you a random number between 101 and 152 for example. ( the end_value variable ).
Note: min is a restricted word ( used by Flash for other functions ) so change as I did to mini and maxi.