当传统补间在第一秒没有使用stop()时如何解决?

问题描述 投票:1回答:1

如何使用stop()命令在动作脚本编码中使用经典补间动作移动对象时如何解决?在我的时间轴上,我的对象在经典的补间动作中运行良好。但是当我按下ctrl enter时,对象不会随着动作移动。

我试过'gotoAndStop'和'gotoAndPlay'命令。

下面的代码是第一个场景编码,还有一个按钮。按下按钮,它将进入场景二。


import flash.events.MouseEvent;

stop();

GWbtn.addEventListener(MouseEvent.CLICK, China);
function China(e:MouseEvent):void{
    gotoAndPlay(1, 'Scene 2');
}

在场景二中,我在对象的时间轴中创建了一个经典的补间,我在编码中包含了stop()命令,如下所示。当ctrl进入时,补间功能不起作用。

import flash.events.Event;
import flash.events.MouseEvent;

stop();

nextbtn1.addEventListener(MouseEvent.CLICK, next1);
function next1(event:MouseEvent):void{
    gotoAndPlay(17);
}

我希望我的对象的输出与经典补间和stop()命令一起移动。

actionscript-3 actionscript
1个回答
1
投票

问题在于场景2帧1具有停止();在你的代码中。这样做是为了停止第16帧上的补间:

import flash.events.Event;
import flash.events.MouseEvent;

//stop(); //remove this line

addEventListener(Event.ENTER_FRAME, checkFrame);
function checkFrame(event:Event):void {
    if (currentFrame == 16) {
        removeEventListener(Event.ENTER_FRAME, checkFrame);
        stop();
    }
}

nextbtn1.addEventListener(MouseEvent.CLICK, next1);
function next1(event:MouseEvent):void{
    nextbtn1.removeEventListener(MouseEvent.CLICK, next1);  //also kindly add this, its good practice
    removeEventListener(Event.ENTER_FRAME, checkFrame);
    gotoAndPlay(17);
}
© www.soinside.com 2019 - 2024. All rights reserved.