【问题标题】:How can I play my animation in reverse on hover in Adobe Animate?如何在 Adob​​e Animate 中悬停时反向播放动画?
【发布时间】:2017-06-07 12:43:45
【问题描述】:

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

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

我能否像使用 Adob​​e Animate 一样使用 Adob​​e Flash 教程?也许这就是我发现 Adob​​e Animate 教程如此之少的原因。

【问题讨论】:

    标签: flash animation actionscript timeline tween


    【解决方案1】:

    我可以像使用 Adob​​e Animate 一样使用 Adob​​e Flash 教程吗?

    是的!如果您想对鼠标悬停/移出做出反应,则使用 ActionScript 3 代码(为方便起见,缩写为 AS3)。

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

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

    • 现在您的动画存在于 MC​​lip 对象中,通过在 Properties 面板的 instance 框中键入 MClip 为 MClip 指定一个实例名称。您的代码通过实例名称引用该对象。

    • 对于代码:只需创建一个名为“操作”或“代码”的新层,然后在其中键入您的 AS3 代码。该层存在于舞台上。所以在舞台上你应该最后有两层(一层用于代码,一层用于保存 MClip,仅在第 1 帧上)。

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

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

    祝你教程顺利。

    【讨论】:

    • 啊....我认为这是我缺少的步骤。一切都没有整齐地隐藏在影片剪辑层中。非常感谢!
    【解决方案2】:

    你也可以这样使用:

    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
        }
    }
    

    因此,当您希望电影剪辑/精灵反向播放时,您只需调用 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();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-08
      • 2016-05-13
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 2015-09-16
      相关资源
      最近更新 更多