我正在开发一个网站,其中包含从上到下覆盖整个舞台的导航项目(请参阅下面的更改图像),用户使用鼠标轻松退出舞台,不会触发“关闭”所述导航项目所需的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