这种情况我遇到了很多,但似乎从来没有找到一个好的解决方案。我有一些影片剪辑,我在翻转时略微放大,但如果你将鼠标悬停在影片剪辑的边缘,它就会坐在那里闪烁,不断接收mouseOver和mouseOut事件。你怎么处理这个?同样,补间动画片段或按钮的比例时通常会出现问题。
my_mc.addEventListener(MouseEvent.MOUSE_OVER, mOver);
my_mc.addEventListener(MouseEvent.MOUSE_OUT, mOut);
private function mOver(m:MouseEvent) {
TweenLite.to(m.target, .2, { scaleX:1.1, scaleY:1.1} );
}
private function mOut(m:MouseEvent) {
TweenLite.to(m.target, .2, { scaleX:1, scaleY:1} );
}
答案 0 :(得分:1)
我知道你的意思:当剪辑扩展/收缩时,动画本身会生成不需要的输入事件,将光标移出或移出剪辑调整大小的hitTest区域。
一些想法:
my_mc.addEventListener(MouseEvent.MOUSE_OVER, _animate);
my_mc.addEventListener(MouseEvent.MOUSE_OUT, _animate);
private function _animate(event:MouseEvent):void
{
var mc:Sprite = event.target as Sprite;
var animScale:Number = (event.type == MouseEvent.MOUSE_OVER) ? 2 : 1;
TweenLite.to(mc, 0.5, {
onStart: function():void {
mc.removeEventListener(MouseEvent.MOUSE_OVER, _animate);
mc.removeEventListener(MouseEvent.MOUSE_OUT, _animate);
},
scaleX: animScale,
scaleY: animScale,
onComplete: function():void {
mc.addEventListener(MouseEvent.MOUSE_OVER, _animate);
mc.addEventListener(MouseEvent.MOUSE_OUT, _animate);
}
});
}