鼠标在闪光灯上时如何重放当前帧?

时间:2012-11-30 20:59:26

标签: actionscript-3 flash

这是我到目前为止所得到的:

stop();

stage.addEventListener(MouseEvent.MOUSE_OVER, playMovie); function playMovie(event) { play(); }
stage.addEventListener(MouseEvent.MOUSE_OUT, stopMovie); function stopMovie(event) { gotoAndStop(0);}


stop();

我正在寻找而不是“gotoAndStop”来自当前帧的反向函数

由于

最高

1 个答案:

答案 0 :(得分:1)

你可以采取一种方式:

//a function you can call and pass in the item/timeline you want played backwards
function goBackwards(item:MovieClip):void {
    item.stop(); //make sure the item isn't playing before starting frame handler below
    item.addEventListener(Event.ENTER_FRAME, moveBackwards); //add a frame handler that will run the moveBackwards function once every frame
}

//this function will move something one frame back everytime it's called
function moveBackwards(e:Event):void {
    var m:MovieClip = e.currentTarget as MovieClip; //get the movie clip that fired the event
    if(m.currentFrame > 1){ //check to see if it's already back to the start
        m.prevFrame();  //if not move it one frame back
    }else{
        m.removeEventListener(Event.ENTER_FRAME,moveBackwards); //if it is (at the start), remove the enter frame listener so this function doesn't run anymore
    }
}

因此,如果您要向后播放的对象名为bob,则可以执行此操作:goBackwards(bob);。如果您想在要回放的时间轴内使用它,请执行goBackwards(this);