Jump to content
GreenSock

lance1572

As2 Restart timelineLite Help

Recommended Posts

Hi all sorry if this has been addressed before. I cannot seem to find anything that is working for me. I'm trying to do a banner that loops 3 times with a delay between the end of timeline and the beginning.

 

All that is happening is it runs through the timeline. It does not delay or restart.

 

I'm okay at as2 but havent delved into as3 and this project requires as2.

 

I've tried a restart function that I had seen in another post but it's not working. I tried it with TimeLineMax and used the repeat and that worked but unfortunately added 10 more k to my swf. I've read some on the docs but still unclear.

 

Any help would be appreciated!!!! Thanks!

 


var timeline:TimelineLite = new TimelineLite({onComplete:done});

timeline.append( TweenLite.to(text_01, .75, {_alpha:100, _xscale: 100, _yscale: 100, ease:Linear.easeOut}));
timeline.append( TweenLite.to(text_01, .5, {_alpha:0, ease:Regular.easeOut}), 1.25);
timeline.append( TweenLite.to(arrowRight, .5, {_x:162, ease:Regular.easeOut}));
timeline.append( TweenLite.to(arrowLeft, .5, {_x:-1, ease:Regular.easeOut}));
timeline.append( TweenLite.to(arrowTop, .5, {_y:155, ease:Regular.easeOut}));

function done() {
TweenLite.delayedCall(4, timeline.restart);
}

Link to comment
Share on other sites

from what I can see, that really should work. don't see anything wrong.

 

can you post a sample fla (cs5 or less) that only includes that code and the assets needed for the timeline?

 

perhaps if I can test it I'll see it better, but it really looks good.

 

strange.

 

 

ps can you add a trace to done() and see if it ever gets fired?

 

function done(){
trace("i'm done");
}

Link to comment
Share on other sites

hey Carl! Thank you for helping!!! I sent you a quick pm of the fla. Its in CS5

Link to comment
Share on other sites

thanks for the file. For now I'm assuming there is some funky as2 scope issue.

for the life of me I couldn't get the following to work:

 

TweenLite.delayedCall(4, timeline.restart)

 

a solution for now is to have the delayedCall call another function which restarts the timeline

 

var timeline:TimelineLite = new TimelineLite({timeScale:1.25, onComplete:done});

timeline.append( new TweenLite(text_01, .75, {_alpha:100, _xscale: 100, _yscale: 100, ease:Linear.easeOut}));
timeline.append( new TweenLite(text_01, .5, {_alpha:0, ease:Regular.easeOut}), 1.25);
timeline.append( new TweenLite(arrowRight, .5, {_x:162, ease:Regular.easeOut}));
timeline.append( new TweenLite(arrowLeft, .5, {_x:-1, ease:Regular.easeOut}));
timeline.append( new TweenLite(arrowTop, .5, {_y:155, ease:Regular.easeOut}));
/* ... the rest of your tweens  */

function done() {
trace('in done')
TweenLite.delayedCall(1, restartTheTimeline);
}


function restartTheTimeline(){
trace("restart");
timeline.restart();
}

Link to comment
Share on other sites

ahhhh as2. just remembered (after a little search) the AS2 version of DelayedCall includes a "scope" parameter after the onCompleteParams.

 

so in your done function just do:

 

function done() {
trace('in done')
TweenLite.delayedCall(1, timeline.restart, [],  _root.timeline);


}

 

that should work fine.

Link to comment
Share on other sites

Thanks Carl! I'll give a whirl!

 

So in essence, correct me if I"m wrong, but the param must reference the scope? OnComplete couldn't find the restart function?

 

Anyhow- thank you very much for the help!!!

Link to comment
Share on other sites

So what I did was just put all of the tweens into a movieclip and looped that.

 

Anyone interested heres what I did:

 


//Loop
var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 2;
var duration:Number = 15000;

function executeCallback():Void {
if(count < maxCount) {
	launchMe();
} else if(count >= maxCount) {
	clearInterval(intervalId);
} 
count++;
}

intervalId = setInterval(this, "executeCallback", duration);

function launchMe():Void {
main.removeMovieClip();
this.attachMovie("Main", "main", getNextHighestDepth(), {_x:0, _y:0});
}

launchMe();



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×