2011-02-05 2 views
0

Je veux montrer un trace("test") à la fin de l'annéeComment savoir quand le yoyo va finir?

Comment savoir quand le yoyo va finir?

J'utilise 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(); 
} 

Répondre

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"); 
    } 
} 

Rob

Questions connexes