Hi all,
I have 2 buttons and 2 objects on my stage. And I inserted a global variable, to control the animation order between these objects. Follows the code:
var lvl:int;
lvl = 0;
var myBack1 = new Tween(mc1, 'y', Regular.easeIn,317,164, 1, true);
myBack1.stop();
var myBack2 = new Tween(mc2, 'y', Regular.easeIn,317, 164, 1, true);
myBack2.stop();
var myTween1 = new Tween(mc1, 'y', Regular.easeIn, 164, 317, 1, true);
myTween1.stop();
var myTween2 = new Tween(mc2, 'y', Regular.easeIn, 164, 317, 1, true);
myTween2.stop();
btn1.addEventListener(MouseEvent.CLICK, onClick1);
function onClick1(e:MouseEvent):void {
if(lvl == 0){
myTween1.start();
lvl = 1;
}
if(lvl == 2){
myBack2.start();
myTween1.start();
lvl = 1;
}
}
btn2.addEventListener(MouseEvent.CLICK, onClick2);
function onClick2(e:MouseEvent):void {
if(lvl == 0){
myTween2.start();
lvl = 2;
}
if(lvl == 1){
myBack1.start();
myTween2.start();
lvl = 2;
}
}
The animation is working perfectly. However, I need that the animation “myTween” wait for the completion of the animation “myBack” to be ran after, whenever appropriate.
How can I do it?
Thanks!