chris-ELM
3/1/2014 - 6:31 PM

Array shuffle prototype

Array shuffle prototype

var tempStr:String = "1,2,3,4,5,6,7,8";
var question_arr:Array = tempStr.split(",");
Array.prototype.shuffle = function() {
	for (var k = this.length-1; k>=0; k--) {
		var p = random(k+1);
		var t = this[k];
		this[k] = this[p];
		this[p] = t;
	}
};
question_arr.shuffle();
trace(question_arr);