如果要运行这两个 MouseEvent,可以添加 removeEventListener 来实现。
function Over (e:MouseEvent):void
{
trace('Over');
var myTweenUp:Tween = new Tween(button, "y", Back.easeOut, 200, 180, 2, true);
button.removeEventListener(MouseEvent.MOUSE_OVER, Over);
}
function Out (e:MouseEvent):void
{
trace('Out');
var myTweenDown:Tween = new Tween(button, "y", Back.easeOut, 180, 200, 2, true);
button.removeEventListener(MouseEvent.MOUSE_OUT, Out);
}
button.addEventListener(MouseEvent.MOUSE_OVER, Over);
button.addEventListener(MouseEvent.MOUSE_OUT, Out);
如果你想制作一个循环,当鼠标悬停在运行 Over 的按钮上并一个接一个地运行 Out 时,你可以尝试下面的编码:
function Over (e:MouseEvent):void
{
trace('Over');
var myTweenUp:Tween = new Tween(button, "y", Back.easeOut, 200, 180, 2, true);
button.removeEventListener(MouseEvent.MOUSE_OVER, Over);
button.addEventListener(MouseEvent.MOUSE_OUT, Out);
}
function Out (e:MouseEvent):void
{
trace('Out');
var myTweenDown:Tween = new Tween(button, "y", Back.easeOut, 180, 200, 2, true);
button.removeEventListener(MouseEvent.MOUSE_OUT, Out);
button.addEventListener(MouseEvent.MOUSE_OVER, Over);
}
button.addEventListener(MouseEvent.MOUSE_OVER, Over);