0

基本上我正在尝试创建两个按钮。当用户将光标放在它们上时,它们都会调用动作(而不是 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);

非常感谢任何帮助:)

4

1 回答 1

1

您应该ENTER_FRAME在 MOUSE_DOWN 上添加一个事件:

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.
    } 
于 2013-09-27T12:32:00.720 回答