I’m working on this project where I give the user 12 options and they can choose 6 to vote on and then submit their choices. I had a little help and this is the code I have now:
var resultArray:Array = [];
var totalPressed:Number = 0;
for (i=0;i<12;i++) {
this.attachMovie("box","box"+i,this.getNextHighestDepth(),{_x:30,_y:10+(30*i)})
this["box"+i].id = i;
this["box"+i].onRelease = function() {
judgeAmount(this,this.id);
};
resultArray.push(-1);
};
function judgeAmount(box:MovieClip,idNo:Number):Void {
if (box._currentframe == 2) {
totalPressed--;
resultArray[idNo] = -1;
box.gotoAndStop(1);
}
else {
if (totalPressed < 6) {
box.gotoAndStop(2);
resultArray[idNo] = 1;
totalPressed++;
}
};
if (totalPressed == 6) submit._alpha = 100;
else submit._alpha = 0
};
Now this works great, but the problem is that it’s generating the boxes from the library and I want the code to point to boxes already on the stage. I know the problem has to with the “for” statement, but I’m not sure how to change it. If anyone has any help they could give I would really appreciate it. Thank you!