Hi,
I have a simple movie that has two tweens happening (two photos going down in scale slightly at the same time, var car and var photo; a background object and a foreground object).
This works fine on the first loop, but nothing happens on the second loop, and
the third loop the foreground object ("car") has been scaled twice, so appears too small, and again no animation happens.
There are some 'position reset' issues here that I don't understand, most of what I try in the 'reset to start position' in the code
makes things worse. Any help gratefully recieved. Thanks..
import com.greensock.*
import com.greensock.easing.*;
import flash.display.MovieClip;
//import flashx.textLayout.operations.MoveChildrenOperation;
var text1:MovieClip;
var photo:MovieClip;
var finalText:MovieClip;
var blackMask:MovieClip;
var button:MovieClip;
var price_text:MovieClip;
var car:MovieClip;
// STARTING STATES
text1.alpha = 0;
finalText.alpha = 0;
price_text.alpha = 0;
button.alpha = 0;
button.x = 370;
blackMask.alpha = 1;
photo.scaleX = 1;
photo.scaleY = 1;
car.scaleX = 1;
car.scaleY = 1;
//ANIMATE SEQUENCE
var max_loops:Number = 3;
var loop_count:Number = 1
var TL:TimelineLite = new TimelineLite({onComplete:countUp});
function playOnce():void {
TL.to(photo, .2, {scaleX:"+=0.1",scaleY:"+=0.1"});
//FADE FINAL TEXT IN
TL.to(blackMask, .4, {alpha:0});
TL.to(photo, 3, {scaleX:"-.09",scaleY:"-.09"},1);
TL.to(car, 2, {scaleX:"-.1",scaleY:"-.1"},1);
TL.to(button, 1.5, {alpha:1}, "-=0.1");
TL.to(text1, 1.5, {alpha:1}, "-=0.1");
TL.to(finalText, 1.5, {alpha:1}, "-=0.1");
TL.to(price_text, 1.5, {alpha:1}, "-=0.1");
TL.to(button, .5, {x:255}, "+=0.5");
//WRAP 'LOOP RESET' TWEENS IN CONDITIONAL, last run ends at FINAL text
if (loop_count<max_loops) {
//FADE FINAL TEXT OUT
TL.add([new TweenLite(blackMask, 1, {alpha:1}),
new TweenLite(button, 0.3, {alpha:0}),
new TweenLite(finalText, 0.3, {alpha:0}),
new TweenLite(text1, 0.3, {alpha:0}),
new TweenLite(price_text, 0.3, {alpha:0}),
new TweenLite(button, 3, {x:370}),
], "+=3");
//RETURN TO START POS
new TweenLite(photo, 0.25, {scaleX:"0.1",scaleY:"0.1"});
new TweenLite(car, 0.25, {scaleX:".1",scaleY:".1"});
new TweenLite(button, 0.3, {alpha:0});
new TweenLite(button, 0.25, {x:370});
new TweenLite(car, 0.25, {scaleX:"0.1",scaleY:".1"}),
TL.play();
}
}
function countUp():void {
loop_count++;
init();
}
function init():void {
if (loop_count<=max_loops) {
trace("played "+loop_count+" times");
playOnce();
}
}
init();