如何知道yoyo什么时候结束?

时间:2011-02-05 19:20:13

标签: actionscript-3 tween

我希望在yoyo结束时显示trace("test")

如何知道yoyo什么时候结束?

我正在使用AS3

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

var myTween = new Tween(my_mc, "x", Strong.easeInOut, 100,300, 1, true);

myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);

function onFinish(e:TweenEvent):void {
    myTween.yoyo();
}

1 个答案:

答案 0 :(得分:2)

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

var myTween = new Tween(my_mc, "x", Strong.easeInOut, 100,300, 1, true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);
var yoyoCounter:uint;

function onFinish(e:TweenEvent):void {
    if(yoyoCounter < 1)
    {
        myTween.yoyo();
        ++yoyoCounter;
    }
    else
    {
        myTween.removeEventListener(TweenEvent.MOTION_FINISH, onFinish);
        trace("test");
    }
}

罗布