If I wanted the range of the random numbers for flash to be between 3 to 8, I would rewrite the below actionscript to..?
(random(3)+1)
Printable View
If I wanted the range of the random numbers for flash to be between 3 to 8, I would rewrite the below actionscript to..?
(random(3)+1)
I'd use: random(6)+3;
g'luck.
The use of random() has been deprecated. You should use Math.random() instead.Per the documentation on LiveDocs, Math.random() will return a number between [0 and 1), or as they write it, 0 <= n < 1. Which means you can potentially return a zero, but never a 1, and anything in-between. So in the previous code, the maximum value you can get will be 5.999999 and never six. Math.floor() will drop the decimal portion of it, returning a number between 0 and 5, add 3, you get between 3 and 8.Code:var someNum:Number = Math.floor( Math.random() * 6 )+3;
trace( someNum );
Of course, if you're looking for decimals as well, get rid of the Math.floor() function :)