Say I have an array:
myList:Array = new Array();
myList = [1,2,3,4,5,6,7,8,9];
myRandomList:Array = new Array();
for (var i:uint = 0; i < myList; i++) {
var item:Number = Math.floor(Math.random() * myList.length-1) + 1;
myRandomList.push(item);
}
The only thing is, I'd like myRandomList to not have any duplicate numbers...is there a way to select a random number from the first list and then SUBTRACT it so I don't select that number twice?
UPDATE:
I just saw this method of shuffling an array from shadetyler.blogspot.com/2008/12/array-shuffle-as3.html
Array.prototype.shuffle = function(){
for(var i = 0; i < this.length; i++){
var a = this[i];
var b = Math.floor(Math.random() * this.length);
this[i] = this[b];
this[b] = a;
}
However, is there a way to rewrite this as a function? }