Actionscript 3 当鼠标离开flash时,如何重放当前帧?

Actionscript 3 当鼠标离开flash时,如何重放当前帧?,actionscript-3,flash,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(); 我正在寻找一种与当前帧相反的函数,而不

到目前为止,我得到的是:

stop();

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


stop();
我正在寻找一种与当前帧相反的函数,而不是“gotoAndStop”

谢谢

Max

一种方法:

//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(此操作)

从当前帧开始的反转功能是什么意思?重放回第一帧。反转回到开始?是的。对不起,我有点菜鸟你怎么用代码?我在回答的末尾添加了用法示例,你把“goBackwards(this);”放在哪里?第二线?相当破旧是件好事吗?你把
goBackward(这个)
(以及代码的其余部分)放在任何你想倒退的时间线上。不,糟糕的是哈哈。什么是“时间表”?你是说图层吗?bob是实例名吗?不知道你叫什么shabby。时间线是你的图层所在的东西。每个movieClip都有一个时间轴(包括根,它是项目的主要时间轴)。时间线由关键帧组成,您可以在其中放置代码和/或符号(图形资源)。