Im having trouble retrieving events from listeners created by a loop in an array.
I can add an event listener to everything in the array without issue, But if I use ‘this’ to try to to see what was clicked on, the event is applied to everyone in that array.
So this code would shrink every one of the sprites, not just the one I clicked on.
So how do I single out pieces with events, using generic code.
Thanks!
for (var i in projects) {
var holder:Sprite = new Sprite();
holder.graphics.beginFill(0x333333);
holder.graphics.drawRect(0,0,100,100);
holder.graphics.endFill();
addChild(holder);
holder.x = pWrapperWidth* (i);
holder.addEventListener(MouseEvent.MOUSE_DOWN, projectDown);
}
function projectDown(event:MouseEvent){
this.width *= .5;
}