PDA

View Full Version : Random number


Platypus2008
04-30-2008, 09:35 AM
Is there a way to make actionscript 3.0 able to choose a random number out of 200 on every enterframe?

creynders
04-30-2008, 09:54 AM
var rnd : int = Math.floor( 200 * Math.random() );

Platypus2008
04-30-2008, 10:35 AM
Hi. Thanks that worked great. What does Math.Floor mean?

DiamondDog
05-02-2008, 03:43 PM
Math.floor(x) = the largest whole number which is less than x

So, for example, Math.floor(4.6) = 4

The fancy name for it is truncation, I think.

amarghosh
05-02-2008, 04:11 PM
and there is Math.ceil for smallest integer greater than given number: for 4.1 it will give 5;

so that the original number is between floor and ceiling ;)