Posted By

mattkenefick on 05/19/08


Tagged

actionscript array an shuffle


Versions (?)

Array: Shuffle


 / Published in: ActionScript
 

  1. Array.prototype._shuffle = function() {
  2. /*
  3. * This replaces original array and does not return a value
  4. */
  5.  
  6. var ary_length = this.length;
  7. for (var i=0; i < ary_length; ++i) {
  8. var randomize = Math.floor(Math.random()*ary_length);
  9. var temp = this[i];
  10. this[i] = this[randomize];
  11. this[randomize] = temp;
  12. }
  13. return this;
  14. }// End Function

Report this snippet  

You need to login to post a comment.