如何在Adobe Animate中悬停时反向播放动画?

时间:2017-01-23 03:53:18

标签: flash animation actionscript timeline tween

我是Adobe Animate(之前使用的Adobe Edge)的新手

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

我是否可以像Adobe Animate一样使用Adobe Flash教程?也许这就是我发现Adobe Animate教程很少的原因。

2 个答案:

答案 0 :(得分:0)

  

我可以像Adobe Animate一样使用Adobe Flash教程吗?

是!!如果您想要某些东西对鼠标翻转/响应做出反应,那么您可以使用ActionScript 3代码(为方便起见,缩写为 AS3 )。

  • 绘制舞台大小的矩形形状(已填充但没有轮廓颜色),然后右键单击以将形状转换为MovieClip类型。

  • 从时间轴中选择所有动画帧,然后剪切&粘贴在新的MClip中(通过双击它来编辑MClip,然后您将被带到MClip本身的时间轴,然后右键单击并粘贴框架#34;)。将MClip视为"迷你舞台"。

  • 现在您的动画存在于MClip对象中,通过在属性面板的instance框内键入,为MClip提供实例名称。您的代码通过其实例名称引用该对象。

  • 对于代码:只需创建一个名为" actions"或"代码"然后在那里输入您的 AS3 代码。该图层存在于舞台上。所以在舞台上你应该最终有两个层(一个用于代码,一个用于保存MClip,所有仅在帧1上)。

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

对于初学者来说,我只能说接受代码来控制特定的MClip向后或向前行进。

祝你好运。

答案 1 :(得分:0)

您也可以使用以下内容:

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()添加参数来指定要使用的动画片段/精灵。当使用这些函数时,您可以使用String作为参数指定对象,并为其提供动画的开始和最后帧编号(例如: 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();
    }
}
相关问题