Hi, I have a function called RandomLocation() that i call from a button and it chooses 6locations on the left side of the screen and then i want it to call 6locations on the right of the screen. The Locations are preset in an array.
Below is the code for the function but when go through the do while once it reaches the end it freezes. Can any one see whats wrong with it?
I have attached the full application fla as well
Code://Value either 6 or 11 Max = 6; //Value either 0 or 6 Min = 0; function RandomLocation(){ //J Stops after its run 6 times if (j <6){ //Flag to check that random number has already been picked var myVar:Number = 0; //Repeat untill you find a random number that has not been picked. do { i = Math.floor(Math.random()*(Max-Min))+Min; // This checks if random number number has already been chosen if (myArr[i] == 0){ trace("myVar: " + myVar+ " Radn="+i + " myArr[i]:" + myArr[i]); myArr[i] = 1; //Set to any value that is not 0 to exit loop myVar = 2; j++; } trace(myVar+"Radn="+i); trace("X=" + pointer_mc._y + " Y=" +pointer_mc._y); pointer_mc._x = TargetLocationArray[i][0]; pointer_mc._y = TargetLocationArray[i][1]; } while (myVar == 0); } else{ RunLeft(); } } function RunLeft(){ //Value either 6 or 11 Max = 11; //Value either 0 or 6 Min = 6; RandomLocation() }


Reply With Quote
