我正在開發一個網站,其中包含從上到下覆蓋整個舞臺的導航項目(請參閱下面的更改圖像),用戶使用鼠標輕鬆退出舞臺,不會觸發「關閉」所述導航項目所需的MouseEvent.MOUSE_OUT
事件。當鼠標離開舞臺時,AS3:MOUSE_OUT不會觸發
我是否應該使用Event.MOUSE_LEAVE
來檢測鼠標何時離開舞臺,並關閉所有啓用的導航項?這就是我一直在努力做的事情,但是從我的聽衆那裏得到任何輸出都有困難。有任何想法嗎?
alt text http://marcysutton.com/blog/wp-content/uploads/2010/01/redpropeller.png
對於在Flash IDE中的MovieClip關聯的類,這是正確的語法註冊一個Event.MOUSE_LEAVE
監聽器?無論我做什麼,它都不會做任何事情。是否需要在瀏覽器中嵌入電影才能觸發該事件?
this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
這裏是我MainNav.as類:
package com.redpropeller {
import com.greensock.*;
import com.greensock.plugins.*;
import flash.display.*;
import flash.text.*;
import flash.events.*;
public class MainNav extends MovieClip { // MainNav is a movieclip in the IDE
public var colors:Array;
public function MainNav():void {
colors = new Array(0xee3124, 0xc72a1f, 0xa62c24, 0x912923, 0x7e221c);
TweenPlugin.activate([TintPlugin]);
// trying to target stage through this object
this.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
for(var i:Number=0; i<this.numChildren; i++){
var n = this.getChildAt(i);
n.useHandCursor = true;
n.buttonMode = true;
n.addEventListener(MouseEvent.MOUSE_OVER, navBtnOn);
n.addEventListener(MouseEvent.MOUSE_OUT, navBtnOff);
}
}
public function mouseLeaveListener(e:Event):void {
trace('mouseleave'); // nothing ever happens
}
private function navBtnOn(e:MouseEvent):void {
TweenLite.to(e.currentTarget.bar_mc, 0.01, {tint:0x333333});
}
private function navBtnOff(e:MouseEvent):void {
TweenLite.to(e.currentTarget.bar_mc, 0.01,
{tint:uint(colors[this.getChildIndex(MovieClip(e.currentTarget))])});
// changes color back to specific tint
}
}
}
那是什麼圖形?您的託管服務是否恢復了一些隨機照片? – jedierikb 2010-01-12 17:10:31
在網站發佈之前發佈實際設計讓我覺得很奇怪....用更好的圖形取代。 – 2010-05-21 17:45:17