Help: Random code selecting removed array item.
Hello struggling with this bit of code.
What im trying to do is whenever pickCircuit function is called, randomly color a button and remove it from the array so it cant be "selected" again.
The problem: my code is still selecting deleted items off the array.
//array
var brkArr:Array = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"];
trace(brkArr);
function pickCircuit (){
//randomizer
var brkRa:Number = Math.ceil(Math.random()*brkArr.length);
trace(brkArr.length);
//change color
var brkPik:ColorTransform = new ColorTransform();
brkPik.blueOffset = 150;
this[("brk" + brkRa)].transform.colorTransform = brkPik;
removeItemArray(brkArr,brkRa);
}
// Code removes items from array
function removeItemArray(thearray , theItem):void{
trace("Remove "+theItem+" from "+thearray );
for(var i:int=0; i<thearray .length;i++){
if(thearray ==theItem){
thearray .splice(i,1);
break;
}
}
trace(" array is now - "+thearray );
}
any help would be appericated