我有一个由代码带到舞台的 MovieClip 实例(电影)。我想为这部电影添加一些鼠标悬停或鼠标按下时的效果。所以,首先我向这个 MovieClip 添加了事件监听器:
movie.addEventListener(MouseEvent.MOUSE_DOWN, movieDownHandler);
movie.addEventListener(MouseEvent.MOUSE_UP, movieUpHandler);
movie.addEventListener(MouseEvent.MOUSE_OVER, movieOverHandler);
movie.addEventListener(MouseEvent.MOUSE_OUT, movieOutHandler);
然后我添加了事件处理程序:
private function movieDownHandler(e:MouseEvent):void {
trace("down");
}
private function movieUpHandler(e:MouseEvent):void {
trace("up");
}
private function movieOverHandler(e:MouseEvent):void {
trace("over");
}
private function movieOutHandler(e:MouseEvent):void {
trace("out");
}
当我测试它时,一切正常:鼠标悬停在这部电影上,描摹,鼠标向下描摹,鼠标向上描摹等等......但是,当我向电影添加尺寸变化时,例如,鼠标向下像这样的处理程序:
private function movieDownHandler(e:MouseEvent):void {
trace("down");
movie.scaleX = 0.9;
movie.scaleY = 0.9;
}
以及一些过度处理程序的过滤效果,例如blurFilter:
private function movieOverHandler(e:MouseEvent):void {
trace("over");
e.currentTarget.filters = [new BlurFilter(1,1,1)];
}
然后我收到事件处理程序的意外行为:鼠标悬停在轨迹上(没关系),然后我在电影中按下(鼠标按下而不释放鼠标按钮),然后三个事件一个接一个发生:'down','out',' over'(鼠标光标不会离开 MovieClip 形状)。问题是什么?此外,将 scaleX 和 scaleY 设置为 1.1 不会破坏处理程序的行为