는 말 배열을 셔플 :에서 임의의 숫자를 선택하는 방법이 ...임의 화 또는 내가 배열이
는 유일하게이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);
}
, 내가 중복 번호를하지 myRandomList 싶습니다을 첫 번째 목록을 누른 다음 SUBTRACT로 두 번 선택하지 마십시오. UPDATE
:
I 단지 그러나 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;
}
에서 배열 셔플이 방법을보고가있다 이것을 함수로 다시 쓰는 방법? }
'array.splice' 함수를 살펴보십시오. –
방금 splice를 사용할 수 있다는 것을 알았지 만 더 빨라야하는 Array.prototype 메서드도 있습니다. shadetyler.blogspot.com/2008/12/array-shuffle-as3.html – redconservatory
배열 셔플에 대한 구현을 시도해보십시오. 여기에 답변 : http://stackoverflow.com/a/25702799/1521021 – Glogo