Random original number generator

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 :slight_smile:

[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]){
usedNum[theNum] = true;
} else {


timer = setInterval(numGen, 1);[/AS]