Jump to content
Search Community

When does TimelineMax start playing?

Zadvorsky test
Moderator Tag

Recommended Posts

Hi.

 

Sorry if this question has been asked before, but I could not find specific posts about it (or maybe my search terms are too generic ;p).

 

Lately, I have been running into issues where a TimelineMax instance will start playing without me calling the play() method. This is a problem for me, because I am using methods that return tweens and timelines, which themselves get nested in other timelines.

 

For example, this code could be in a button class:

public function show():TweenCore
{
var timeline:TimelineMax = new TimelineMax();

timeline.insert(new TweenMax(background, 0.4, {alpha:1});
timeline.insert(new TweenMax(icon, 0.4, {alpha:1});

return timeline;
}

and outside the button class:

var timeline:TimelineMax = new TimelineMax();

for each(var button:ButtonClass in buttons)
{
timeline.append(button.show())
}

timeline.play();

 

Now sometimes, the timeline returned by the show method will begin playing, even if I do not call timeline.play(), and sometimes it will not. I was under the impression that a TimelineMax instance would not start playing until the play method was called, but now I am just confused.

 

How does TimelineMax decide when to start playing? Is there anything I can do to control it? Or am I just missing something obvious?

Link to comment
Share on other sites

TimelineLite/Max will always play as soon as they are created (i'm pretty sure it renders on the first ENTER_FRAME that occurs after your code executes) unless you tell them to be paused.

 

a simple test

 

var timeline:TimelineMax = new TimelineMax();

timeline.insert(new TweenMax(background, 0.4, {alpha:1});
timeline.insert(new TweenMax(icon, 0.4, {alpha:1});

 

it will play automatically without needing to call timeline.play()

 

 

 

 

What you will need to do in your case is pause the parent TimelineMax and then tell it to play when you want.

 

 

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

for each(var button:ButtonClass in buttons)
{
timeline.append(button.show())
}

timeline.play();

 

the nested TimelineMax's will not play until the parent TimelineMax is told to play.

 

let me know if that works

 

Carl

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...