Hi there,
I need to create a function that will generate a random number, but not one that has already been generated. This script does work, but it also tells me I have an infinite loop in there, so its not working properly. Any suggestions anyone? Thanks
[AS]usedNum = new Array();
//populate the array
for (i=1; i<50; i++){
usedNum* = false;
}
function numGen(){
var theNum:Number = random(50)+1;
if (!usedNum[theNum]){
trace(theNum);
usedNum[theNum] = true;
} else {
numGen();
}
}
timer = setInterval(numGen, 1);[/AS]