如何在 Adob​​e Animate 中悬停时反向播放我的动画?

How can I play my animation in reverse on hover in Adobe Animate?

我是 Adob​​e Animate 新手(之前使用过 Adob​​e Edge)

我有一个完整的动画(多层)我想在悬停时反向播放(并在悬停时停止反向播放)。

我可以完全按照用于 Adob​​e Animate 的方式使用 Adob​​e Flash 教程吗?也许这就是我发现 Adob​​e Animate 教程如此之少的原因。

Can I use Adobe Flash tutorials exactly as they are for Adobe Animate?

是的!!如果你想让某些东西对鼠标做出反应 over/out 那么你可以使用 ActionScript 3 代码(为方便起见缩写为 AS3)。

  • 绘制一个 Stage-sized 矩形(填充但没有轮廓颜色)然后 right-click 将形状转换为 MovieClip 类型。

  • Select 时间轴中的所有动画帧,然后剪切并粘贴到新的 MClip 中(通过 double-clicking 编辑 MClip,然后您将被带到时间轴MClip 本身,然后 right-click 和 "paste frames")。将 MClip 视为 "mini Stage".

  • 现在您的动画存在于 MC​​lip 对象中,通过在 属性面板。您的代码通过实例名称引用该对象。

  • 对于代码:只需创建一个名为 "actions" 或 "code" 的新图层,然后在其中键入您的 AS3 代码。该层存在于舞台上。所以在 Stage 上你最终应该有两层(一层用于代码,另一层用于保存 MClip,全部仅在第 1 帧上)。

  • 注意 : 放在frame X上的代码只能控制frame X上的其他资源(可以是不同的层,但必须与代码存在于相同的帧号上)。

这就是我可以对初学者说的所有设置,接受代码来控制特定 MClip 向后或向前移动。

祝教程顺利。

你也可以这样使用:

public function playInReverse(){
    your_mc.stop(); //your_mc is the movieclip/sprite you want to play in reverse
    this.addEventListener(Event.ENTER_FRAME, reverseEvent);
}

public function playNormally(){
    this.removeEventListener(Event.ENTER_FRAME, reverseEvent);
    your_mc.play();
}

private function reverseEvent(evt:Event){
    //if your_mc is on the first frame, go to the last frame. Otherwise, go to previous frame.

    if(your_mc.currentFrame == first_frame){ //first_frame is the number or name of the first frame of the animation
        your_mc.gotoAndStop(last_frame); //last_frame is the number or name of the last frame of the animation

    }else{
        your_mc.prevFrame(); //go to the previous frame
    }
}

所以当你想让 movieclip/sprite 反向播放时你只需要调用 playInReverse(); 当你想让它正常播放时你调用 playNormally(); .

此外,您可以通过向 playNormally()playInReverse() 添加参数来指定使用哪个 movieclip/sprite。当使用这些函数时,您可以使用字符串指定对象作为参数,并为其提供动画的开始和最后一帧编号(例如:playInReverse("your_mc_1", 1, 100) ;(或)playInReverse("your_mc_2", 14, 37); ):

private var reversing_mc:String;
private var first_frame:int;
private var last_frame:int;

public function playInReverse(the_mc:String, first_frame_number:int, last_frame_number:int){
    this[the_mc].stop();
    reversing_mc = the_mc;
    first_frame = first_frame_number;
    last_frame = last_frame_number;
    this.addEventListener(Event.ENTER_FRAME, reverseEvent);
}

public function playNormally(the_mc:String){
    this.removeEventListener(Event.ENTER_FRAME, reverseEvent);
    this[the_mc].play();
}

private function reverseEvent(evt:Event){
    if(your_mc.currentFrame == first_frame){
        this[reversing_mc].gotoAndStop(last_frame);

    }else{
        this[reversing_mc].prevFrame();
    }
}