我正在尝试制作图片库。
添加缩略图的容器类如下...
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]);
}
从Image类中,我如何禁用事件监听器(MouseEvent.CLICK,shiftStack)。我希望能够在Image类中添加一个全屏按钮,但无论何时单击它,你知道的shiftStack方法也会被调用。
答案 0 :(得分:4)
如果我做对了,你可以在调用shitStack时删除它
function shiftStack(event:MouseEvent):void{
event.currentTarget.removeEventListener(MouseEvent.CLICK, shiftStack);
//do other stuff here
}