Wednesday, December 13, 2017 02:10 am EST

Randomly Shuffle an Array Using ActionScript 3

Bri's picture

If you have ever wanted to randomly re-arrange the elements of an array after they are already set, try using this function.

function randomizeArray(array:Array):Array
var newArray:Array = new Array();
while(array.length > 0){
var randomIndex = Math.floor(Math.random()*array.length);
array.splice(randomIndex, 1)
return newArray;

The function takes in the array that you want to be modified and returns a new one.


Anonymous's picture

The IT students are more eager

The IT students are more eager to learn about the computer programming. They want to write the piece of code to create high quality games and other softwares but it's not so is essayontime legit to do so. If we talk about array then we can store the data or information in a pattern with the specific address.

Anonymous's picture

Thank you so much for sharing

Thank you so much for sharing the coding script with us that is quite helpful for me to complete my code. I was looking for randomly shuffle number code for the different results. Here on your review website I found quite useful help. Thanks for sharing it.

Anonymous's picture

Throws a warning. You forgot

Throws a warning. You forgot to specify the type of randomIndex (int)

Bri's picture


Thank you. I have not used ActionScript in a loooooong time. Thanks for the correction!