ryan
ryan

Reputation: 1354

as3: how to disable event listener

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.

Upvotes: 1

Views: 5163

Answers (1)

George Profenza
George Profenza

Reputation: 51837

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
}

Upvotes: 4

Related Questions