我有两个电影剪辑。当 .left 悬停在动画上时 .box 播放从右到左移动,但在 .left 未悬停时停止。
我希望 .right 也能发生同样的情况,但动画 .box 会反向播放。我可以实现所有这些,除了当 .right 没有悬停时我无法让动画停止反向播放,它只会继续直到 .box 再次开始。
最终我想把这个概念变成水平网站的滚动。提前致谢。
这是我到目前为止的代码......
import flash.events.MouseEvent;
left.addEventListener(MouseEvent.MOUSE_OVER,left_scroll_over);
left.addEventListener(MouseEvent.MOUSE_OUT,left_scroll_off);
right.addEventListener(MouseEvent.MOUSE_OVER,right_scroll_over);
right.addEventListener(MouseEvent.MOUSE_OUT,right_scroll_off);
//scrolling left
function left_scroll_over(e:MouseEvent):void
{
box.play();
right.visible = true;
}
function left_scroll_off(e:MouseEvent):void
{
box.stop();
if (box.currentFrame == 59)
{
left.visible = false;
right.visible = true;
}
}
// scrolling right
function right_scroll_off(e:MouseEvent):void
{
box.stop();
}
function right_scroll_over(e:MouseEvent):void
{
this.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
}
function playReverse(e:Event):void
{
if (box.currentFrame == 1)
{
stopPlayReverse();
right.visible = false;
left.visible = true;
}
else
{
box.prevFrame();
left.visible = true;
}
}
function stopPlayReverse():void
{
if (this.hasEventListener(Event.ENTER_FRAME))
{
this.removeEventListener(Event.ENTER_FRAME, playReverse);
}
}