ActionScript 3 Random Value Generation Random value from an array

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any ActionScript 3 Question?