Random Numbers in ActionScript

April 15th, 2009 by Brian Leave a reply »

To create a random number in ActionScript:

Math.round();

but that will give you crazy decimals.

Add onto that code:

Math.round(Math.random());

to give you prettier numbers to work with.

To give you a number between 1 and 10, use some multiplication:

Math.round(Math.random()*10);

Try putting this with some _x or _y actions.

Advertisement

Leave a Reply