Jump to content
Search Community

TimelineMax - play and stop

Hippiesvin test
Moderator Tag

Recommended Posts

Hi jack

A quick question.

In tweenGroup I could call a function when the group was onComplete like this myTweengroup.onComplete = myFunction;

How do I do that withTimelineMax?

 

Just wondering. Any particular reason for having TimelineMax's "timeline" running from declareration point and not from when you tell it to play()?

In the following example animation will begin with mcB, while mcA just jumps into place.

I know I can solve this like this var TM:TimelineMax = new TimelineMax(); TM.stop();

 

import flash.display.*;
import com.greensock.TimelineMax;
import com.greensock.TweenMax;
import com.greensock.easing.*;

var mcA:MovieClip = new mc1();	this.addChild(mcA);
var mcB:MovieClip = new mc2();	this.addChild(mcB);

mcA.x = 50;	mcB.x = 150;

var TM:TimelineMax = new TimelineMax();

function animate() {
TM.append(new TweenMax(mcA, 1, {y:50, ease:Back.easeOut}));
TM.append(new TweenMax(mcB, 1, {y:50, ease:Back.easeOut}));
TM.play();
}

setTimeout(animate,1000);

Link to comment
Share on other sites

In tweenGroup I could call a function when the group was onComplete like this myTweengroup.onComplete = myFunction; How do I do that withTimelineMax?

 

Just set it through the vars object, just like in TweenLite/Max:

 

var myTimeline:TimelineMax = new TimelineMax({onComplete:myFunction});

 

Or you can addEventListener() to listen for a TweenEvent.COMPLETE event in AS3.

 

Just wondering. Any particular reason for having TimelineMax's "timeline" running from declareration point and not from when you tell it to play()?

 

Yep, there is actually a very important reason for this. It has to do with nesting and how perplexing it would be for users if they had to play() every nested timeline in order to get the parent timeline to play as expected. Trust me, it's MUCH better that a timeline plays by default, and it is consistent with the way tweens work as well. If you want a timeline to be paused initially, just use the "paused" special property in the vars object like this:

 

var myTimeline:TimelineMax = new TimelineMax({paused:true});

 

Wasn't that easy? :)

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.
×
×
  • Create New...