【发布时间】:2011-01-01 20:50:30
【问题描述】:
我正在开发一个网站,其导航项目从上到下覆盖整个舞台(见下图更改后的图片),用户很容易用鼠标退出舞台,而不触发所需的MouseEvent.MOUSE_OUT 事件“关闭”所述导航项目。
我应该使用Event.MOUSE_LEAVE 来检测鼠标何时离开舞台,并关闭任何启用的导航项吗?这就是我一直在尝试做的事情,但是在从我的听众那里获得任何输出时遇到了麻烦。有什么想法吗?
alt text http://marcysutton.com/blog/wp-content/uploads/2010/01/redpropeller.png
对于与 Flash IDE 中的影片剪辑关联的类,这是注册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
}
}
}
【问题讨论】:
-
那个图形是怎么回事?您的托管服务是否恢复为随机照片?
-
在网站启动之前发布实际设计让我感到很奇怪......替换为更好的图形。
标签: actionscript-3 ide stage mouseout mouseleave