Help: Random code selecting removed array item.
hello struggling bit of code.
what im trying whenever pickcircuit function called, randomly color button , remove array cant "selected" again.
the problem: code still selecting deleted items off array.
//array
var brkarr:array = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","2 0","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 array
function removeitemarray(thearray , theitem):void{
trace("remove "+theitem+" "+thearray );
for(var i:int=0; i<thearray .length;i++){
if(thearray [i]==theitem){
thearray .splice(i,1);
break;
}
}
trace(" array - "+thearray );
}
any appericated
use:
//array
var brkarr:array = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","1 6","17","18","19","20","21","22","23","24","25","26","27","28","29","3 0"];
trace(brkarr);
function pickcircuit (){
//randomizer
var brkra:number = math.floor(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 array
function removeitemarray(thearray , theitem):void{
trace("remove "+theitem+" "+thearray );
thearray .splice(theitem,1);
trace(" array - "+thearray );
}
More discussions in ActionScript 3
adobe
Comments
Post a Comment