动画序列与as3

时间:2012-11-20 09:56:48

标签: actionscript-3 animation sequence tween

我陷入困境,我想在Flash AS3中执行一系列动画。我可以使用TweenClass为我的动画片段设置动画,但不能让它们在序列中相互播放。

我希望在evntInTween完成播放后播放closeTween。

我使用的代码是:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;





BtnEvent.buttonMode = true;
BtnEvent.addEventListener(MouseEvent.ROLL_OVER, EventOver);
BtnEvent.addEventListener(MouseEvent.ROLL_OUT, EventOut);
BtnEvent.addEventListener(MouseEvent.CLICK, EventClick);


 function EventOver(event:MouseEvent) {
    event.target.gotoAndPlay(2);
}

 function EventOut(event:MouseEvent) {
    event.target.gotoAndPlay(11);
}


 function EventClick(event:MouseEvent) {
  var evntInTween:Tween = new Tween(eventzmov, "y", Strong.easeOut, 463.75, 1794.6, 3, true);


  var closetween:Tween = new Tween(closeevent, "alpha", Strong.easeOut, 0, 1, 3, true);



}

2 个答案:

答案 0 :(得分:0)

我认为你应该嵌套补间,所以只有在第一个补间停止播放后才会创建第二个补间 - 它会在结束后发送fl.transitions.TweenEvent.MOTION_FINISH个事件,所以你要为你的按钮分配一个监听器来监听它,一旦不再需要,不要忘记放弃。

function EventClick(event:MouseEvent) {
    var evntInTween:Tween = new Tween(eventzmov, "y", Strong.easeOut, 463.75, 1794.6, 3, true);
    event.target.addEventListener(TweenEvent.MOTION_FINISH,startSecondTween);
    evntInTween.start();
}
function startSecondTween(e:TweenEvent):void {
    var closetween:Tween = new Tween(closeevent, "alpha", Strong.easeOut, 0, 1, 3, true);
    event.target.removeEventListener(TweenEvent.MOTION_FINISH,startSecondTween);
    closetween.start();
}

}

答案 1 :(得分:0)

我强烈建议通过greensock切换到Tweening库TweenLite(又名TweenMax)。使用如下语法:

//TweenLite.to(objectToTween, timeToTween, {propertyOne:value, propertyTwo:value, onComplete: functionToCallWhenFinished});
TweenLite.to(object, 4, {y:50, alpha:0, onComplete:finishedTween, ease:Quad.easeOut});

TweenMax(功能更丰富的TweenLite版本)还有一个TimeLine类,可以在几行代码中编写复杂的动画。

https://www.greensock.com/tweenmax/