Random Numbers

Randomize

Randomization is useful for adding variations to the experience that produce a much organic feel. Adding randonmess to what and when can also make an interactive experience unpredictable and add a surprise element. Adobe help with math, HERE

Math.random()
Generates a random number >=0 and <1 (so 1 can never be its value)

You can also use it as en expression to generate a number within any range:

Math.random() * (max of the range - min of the range) + min of range

Math.random() * (11-5) + 5 Will generate a random number bettwen 5 and 11.
Math.random() * 20 Will generate a random number between 0 and 20
Math.round(Math.random()*80) Will generate a random number between 1 and 80
x=10+Math.floor(Math.random()*6) Find a random integer between 10 and 15, inclusive


x=high + Math.floor(Math.random() * (high-low+1) );

To configure a number to randomly fall within a range of numbers, use the following format:

Math.floor(Math.random()*(1+High - Low) + Low;

Math.floor(Math.random() * (41 + 10); High refers to the largest number in your range, and
Low
refers to the lowest number in your range.
As an example how to get a number between 10 and 50.
41 is the result of (1+(50-10)
Public static functions Math.floor rounds down to the nearest integer (positive or negative number)
Math.round rounds up to the nearest integer

Simple use on a timeline:
gotoAndStop (Math.random() *6

Tutorials