ActionScript 3 Random Value Generation Random value from an array


Example

Assuming we have an array myArray:

var value:* = myArray[int(Math.random() * myArray.length)];

Note we use int to cast the result of Math.random() to an int because values like 2.4539543 would not be a valid array index.