2009-08-26 185 views
1

即時嘗試製作圖片庫。as3:如何禁用事件監聽器

容器類,增加了縮略圖如下...

 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]); 
     } 

從圖像類,我如何禁用事件偵聽器(MouseEvent.CLICK,shiftStack)內。我希望能夠在Image類中添加一個全屏按鈕,但是每當它被點擊時,你所知道的shiftStack方法也會被調用。

回答

4

如果我這樣做是正確,你可以刪除它時shitStack被調用

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

哈哈... ... shitStack HTTP://www.youtube.com/watch V = CJQU22Ttpwc – mheavers 2011-03-14 16:10:00

+0

@ mheavers ..... ssssshhhh! :P – 2011-03-14 16:53:08