1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Array.prototype.shuffle = function() { var randomizedArr:Array = new Array(); var numElementsLeft:int = this.length; while (numElementsLeft) { var index:int = Math.floor(Math.random() * numElementsLeft); randomizedArr.push(this[index]); this.splice(index, 1); numElementsLeft--; } for (var i:int=0; i<randomizedArr.length; i++) this[i] = randomizedArr[i]; } |
Recent Comments