views:

411

answers:

1

im trying to make an image gallery.

the container class that adds the thumbnail as follows...

     for (i=0; i < xmlLength; i++)
  {
   thumbnail[i] = new Image(relPath + "/images/" + imageList[i], imageTitle[i], stage);
   thumbnail[i].addEventListener(MouseEvent.CLICK, shiftStack);
   thumbnail[i].addEventListener(MouseEvent.MOUSE_OVER, trackIt);
   thumbnail[i].name = "image_" + i;
   thumbnail[i].buttonMode = true;
   thumbnail[i].useHandCursor = true;

   if (i != xmlLength - 1){
    thumbnail[i].rotation = (Math.random() * rot) - 8;
   }
   galleryContainer.addChild(thumbnail[i]);
  }

from within the Image class, how do i disable the event listener (MouseEvent.CLICK, shiftStack). I want to be able to add a full screen button within the Image class but whenever it's clicked, the shiftStack method as you know it also gets called.

+3  A: 

If I got it right, you can just remove it when shitStack gets called

function shiftStack(event:MouseEvent):void{
event.currentTarget.removeEventListener(MouseEvent.CLICK, shiftStack);
//do other stuff here
}
George Profenza