array shuffle flash AS2


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. static public function shuffle(orgArray:Array):Array{
  2. var newArray = new Array();
  3. while (orgArray.length>0){
  4. newArray.push(orgArray.splice(randomRange(0,orgArray.length), 1));
  5. }
  6. return newArray;
  7. }
  8.  
  9. static public function randomRange(min:Number,max:Number){
  10. if(min==null)min=Number.NEGATIVE_INFINITY;
  11. if(max==null)max=Number.POSITIVE_INFINITY;
  12. return Math.floor(Math.random()*(max-min)+min)
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.