基本上我正在尝试创建两个按钮。当用户将光标放在它们上时,它们都会调用操作(而不是onClick或类似的东西)。
第一个播放时间轴,效果很好。
第二个我需要它在用户按住按钮时反向播放时间轴,我该怎么做?代码如下:
import flash.events.MouseEvent;
// Play timeline forwards on click //
function onButtonClick( event:MouseEvent ):void
{
play();
}
RotateRight.addEventListener(MouseEvent.MOUSE_DOWN, onButtonClick);
// Stop timeline forwards on release //
function onButtonClick2( event:MouseEvent ):void
{
stop();
}
RotateRight.addEventListener(MouseEvent.MOUSE_UP, onButtonClick2);
// Play timeline in reverse on click //
function onButtonClick3( event:MouseEvent ):void
{
// PLAY IN REVERSE?
}
RotateLeft.addEventListener(MouseEvent.MOUSE_DOWN, onButtonClick3);
// Stop timeline in reverse on release //
function onButtonClick4( event:MouseEvent ):void
{
stop();
}
RotateLeft.addEventListener(MouseEvent.MOUSE_UP, onButtonClick4);
非常感谢任何帮助:)
答案 0 :(得分:1)
您应该在MOUSE_DOWN上添加ENTER_FRAME
个事件:
RotateLeft.addEventListener(MouseEvent.MOUSE_DOWN, onButtonClick3);
function onButtonClick3( event:MouseEvent ):void
{
stop();
stage.addEventListener(Event.ENTER_FRAME, reverse);
}
function reverse(e:Event):void {
//currently, this is reversing the main timeline. Can also do it to a specific movieclip with something like myMovieClip.gotoAndStop(myMovieClip.currentFrame-1) instead.
gotoAndStop(currentFrame - 1);
}
RotateLeft.addEventListener(MouseEvent.MOUSE_UP, onButtonClick4);
// Stop timeline in reverse on release //
function onButtonClick4( event:MouseEvent ):void
{
stage.removeEventListener(Event.ENTER_FRAME, reverse);
//You don't need stop() here, but you can change it to play() if you want to resume playback when the mouse is released.
}