2012-08-14 12 views
0

我很努力使我的動畫工作在屏幕的單獨區域引起狀態在懸停時出現/消失並在其他位置如果點擊則轉到其他位置,但是,如果您點擊一秒鐘就會出現該標籤,然後返回到開始。有什麼建議麼?mouseEnabled + MOUSE_OVER衝突

//mouse overs (i've only left 1 instance of each event listener here) 
comic.addEventListener(MouseEvent.MOUSE_OVER,BubbleHover); 
//mouse outs 
comic.addEventListener(MouseEvent.MOUSE_OUT,BubbleOut); 
//mouse down 
comic.addEventListener(MouseEvent.CLICK,BubbleClick); 


// 
// Take the playhead to where the user hovers. 
// 
function BubbleHover(evtObj:MouseEvent) { 
    var LabelName:String = evtObj.target.name + "Bubble"; 
    trace(evtObj.target.name +" bubble appeared"); //state which bubble appears 
    //go to the section clicked on... 
    gotoAndStop(LabelName); 

} 
// 
// Return to the beginning bubble 
// 
function BubbleOut(evtObj:Event):void{ 

    gotoAndStop("lookBubble"); 
} 

// 
// Go to the Label Page 
// 
function BubbleClick(evtObj:Event){ 

    var MovieClipPage = evtObj.target.name +"_page"; 
    if (mouseEnabled) { 
     mouseEnabled=false; 
     trace(mouseEnabled); // returns false but then returns to "lookBubble" 
    } 
    gotoAndStop(MovieClipPage); 
    mouseEnabled(true); 


} 

據我瞭解正在發生的事情,當播放頭轉到BubbleClick標籤時,MouseEvent.MOUSE_OUT發生。任何想法我怎麼能繞過這個?

+0

我現在已經解決了這個問題:'BubbleOut()'函數中的if(this.currentLabel!=「comic_page」){}'但是它只運行一次。有任何想法嗎? – Neilisin 2012-08-14 11:31:18

回答

0

是的,不幸的是,似乎你已經發現在動作中的幾個怪癖之一。問題是,如果一個影片剪輯有一個鼠標外出事件,並且鼠標懸停在該對象上。如果將mouseEnabled和mouseChildren設置爲false,則該事件仍將觸發,這並不重要。

處理此問題的方法是手動檢查某個布爾狀態(isReallyEnabled)或刪除事件偵聽器。

+0

謝謝你回到我身邊。是的,我問這個問題已經很長時間了。你會建議在其他事件監聽器函數上放置一個'setTimeout'並刪除MOUSE_OUT? – Neilisin 2012-09-27 21:49:09

+1

1)認爲你應該使用ROLL_OVER,ROLL_OUT代替 2)最好的解決辦法可能是: 在BubbleClick功能: 「acceptInput =假」 在BubbleOut功能: 「如果(acceptInput)gotoAndStop(.. 。)「; in BubbleOver-function: 「acceptInput = true」 – 2012-09-28 22:32:03