Posted By

adrianparr on 11/07/09


Tagged

array shuffle


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

weavermedia
davidino1978


Shuffle an Array


 / Published in: ActionScript 3
 

URL: http://flassari.is/2009/04/as3-array-shuffle/

  1. private function shuffleArray($array:Array):Array
  2. {
  3. var shuffledArray:Array = new Array();
  4.  
  5. while ($array.length > 0) {
  6. shuffledArray.push($array.splice(Math.round(Math.random() * ($array.length - 1)), 1)[0]);
  7. }
  8.  
  9. return shuffledArray;
  10. }

Report this snippet  

You need to login to post a comment.