K, so I’ve populated a grid out of a Box class in the library. I’m trying to make sure it works and stuff, and uh, it doesn’t. I have a Mouse Event going, but it only affects one box out of the 30 on the stage, and I have no idea why. The trace statement works with every one. Same with a buttonMode = true. Could someone take a look and point me in the right direction? I’ll attach my .fla in addition to the code below.
import caurina.transitions.Tweener;
var spacing:Number = 10;
var box:Box = new Box();
var numberofRows:Number = 0;
var numberofCols:Number = 0;
for (var i:Number = 0; i<30; i++) {
box = new Box();
box.x = (box.width+spacing) * numberofRows;
box.y = (box.height+spacing) * numberofCols;
addChild(box);
box.x = 120 + (box.width+spacing) * numberofRows;
box.y = 50 + (box.height+spacing) * numberofCols;
box.buttonMode = true;
box.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
box.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
box.addEventListener(MouseEvent.CLICK, clickHandler);
function overHandler(event:MouseEvent):void {
Tweener.addTween(box, {alpha:.25, time:1.5});
trace("alpha down");
}
function outHandler(event:MouseEvent):void {
Tweener.addTween(box, {alpha:1, time:2});
trace("alpha back up");
}
function clickHandler(event:MouseEvent):void {
removeChild(box);
}
if (numberofRows >= 5) {
numberofRows = 0;
numberofCols++;
} else {
numberofRows++;
}
}