random (Math.random method)

public static random() : Number

Returns a pseudo-random number n, where 0 <= n < 1. The number returned is called a "pseudo-random" number because it is, technically, calculated in an undisclosed manner.

Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non-emulated math functions that Flash Player 5 supports.

Returns

Number - A number.

Example

The following example outputs 100 random integers between 4 and 11 (inclusively):

function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}
for (var i = 0; i < 100; i++) {
    var n:Number = randRange(4, 11)
    trace(n);
}

Flash CS3