Jump to content
Search Community

Timeline to play always

moxol test
Moderator Tag

Recommended Posts

I have set var mainTimeline:TimelineMax in order to append TweenMax animations so they can play in order.

Now, lets say I append 3 TweenMax's to timeline and they play all and finish, and after some time I want to append new TweenMax to play, but they don't play unless I do a restart.

 

My intention is to use mainTimeline to play imediatelly TweenMax's always when I append them, but I always need to do restart (even play() won't play them) if I do that.

 

Can I get some explanation how to do that properly?

Link to comment
Share on other sites

Hi Moxol,

 

Please confirm that you are using the latest GSAP files.

 

The behavior you are after is present in

 

v11: TimelineLite 1.699

and

v12

 

We strongly suggest upgrading to v12.

 

Either way, the following test will append a tween to a timeline. Regardless of whether or not the timeline is done playing, the newly added tweens will always play at the right time without forcing the timeline to play()

 

 

import com.greensock.*;
import flash.events.MouseEvent;

trace("**** TimelineLite V: " + TimelineLite.version);

//create timeline
var tl:TimelineMax = new TimelineMax();
tl.insert(TweenLite.to(mc, 1, {x:100}));


stage.addEventListener(MouseEvent.CLICK, addTween);

//append new tween when you click the stage
function addTween(e:MouseEvent):void {
tl.append(TweenMax.to(mc, 1, {y:mouseY, x:mouseX}));
}

 

To test the swf, click a few times on the stage. You will build a series of tweens that will move mc to wherever you clicked. CS5 fla attached.

 

Let us know if this is the behavior you are expecting and it works for you with the latest GSAP.

 

-C

appendAndPlay_CS5.zip

Link to comment
Share on other sites

Yes, I wanted to confirm that you had 1.699 of TimelineLite

 

If you look in com/greensock/changelog.txt you will see that your issue was specifically addressed in the 1.699 update to TimelineLite.

 

 

TimelineLite 1.699

- Added logic to TimelineLite/Max so that if you insert/append a child that extends the duration and the timeline had already finished, it will adjust its startTime and resume playback (as long as it wasn't paused of course)

 

TimelineLite and TimelineMax are different tools that can possibly be revised at different times. The functionality that we are discussing was added to TimelineLite 1.699

 

Since TimelineMax inherits functionality from TimelineLite it is imperative that you have the latest TimelineLite.

 

Please let us know if TimelineLite 1.699 is not performing as expected.

 

-c

Link to comment
Share on other sites

Yes, I wanted to confirm that you had 1.699 of TimelineLite

 

If you look in com/greensock/changelog.txt you will see that your issue was specifically addressed in the 1.699 update to TimelineLite.

 

 

 

 

TimelineLite and TimelineMax are different tools that can possibly be revised at different times. The functionality that we are discussing was added to TimelineLite 1.699

 

Since TimelineMax inherits functionality from TimelineLite it is imperative that you have the latest TimelineLite.

 

Please let us know if TimelineLite 1.699 is not performing as expected.

 

-c

 

I am a bit confused.

If I download TimelineLite 11.699 will I get TimelineMax or not?

Link to comment
Share on other sites

Are you absolutely certain you have updated the greensock files that the fla is compiling with? Could you have an old swc laying around?

 

What does the changlelog.txt file say when you read the latest one when you open it? Does it mention 1.699?

 

What if you open the latest timelinelite.as file, do you see the version number?

 

I just downloaded the latest v11 GSAP and it contains TimelineLite 1.699

 

Just to make things easy I have attached a new zip with the latest GreenSock files so atleast you can compile my fla and see that it works.

 

Please keep me informed with what you find. I can't really understand how you are not getting TimelineLite 1.699 from the public download link.

 

c

appendAndPlay_CS5_GSAP.zip

Link to comment
Share on other sites

Are you absolutely certain you have updated the greensock files that the fla is compiling with? Could you have an old swc laying around?

 

What does the changlelog.txt file say when you read the latest one when you open it? Does it mention 1.699?

 

What if you open the latest timelinelite.as file, do you see the version number?

 

I just downloaded the latest v11 GSAP and it contains TimelineLite 1.699

 

Just to make things easy I have attached a new zip with the latest GreenSock files so atleast you can compile my fla and see that it works.

 

Please keep me informed with what you find. I can't really understand how you are not getting TimelineLite 1.699 from the public download link.

 

c

 

In TimelineLite.as file version is 1.699, but I am using greensock.swc and version is 1.698.

Link to comment
Share on other sites

I can confirm that the swc does use TimelineLite 1.698

Expect an update sometime soon.

 

In the meantime the greensock .as files should work fine.

 

-c

 

OK, when do you expect final v12 to be released?

Link to comment
Share on other sites

Hi Moxol,

 

Please confirm that you are using the latest GSAP files.

 

The behavior you are after is present in

 

v11: TimelineLite 1.699

and

v12

 

We strongly suggest upgrading to v12.

 

Either way, the following test will append a tween to a timeline. Regardless of whether or not the timeline is done playing, the newly added tweens will always play at the right time without forcing the timeline to play()

 

 

import com.greensock.*;
import flash.events.MouseEvent;

trace("**** TimelineLite V: " + TimelineLite.version);

//create timeline
var tl:TimelineMax = new TimelineMax();
tl.insert(TweenLite.to(mc, 1, {x:100}));


stage.addEventListener(MouseEvent.CLICK, addTween);

//append new tween when you click the stage
function addTween(e:MouseEvent):void {
tl.append(TweenMax.to(mc, 1, {y:mouseY, x:mouseX}));
}

 

To test the swf, click a few times on the stage. You will build a series of tweens that will move mc to wherever you clicked. CS5 fla attached.

 

Let us know if this is the behavior you are expecting and it works for you with the latest GSAP.

 

-C

 

I have tried this simple test, and it works, but my program is lot more complex and there it doesn't work.

I have tried both v11 and v12 but they don't play newly appended TweenMax unless I do manual restart.

Link to comment
Share on other sites

As for v12 being final, the AS3 version is rock-solid. The only reason it is still in beta is because there is still work that needs to be done on the javascript version. The goal is to move AS2/AS3 and JS versions out of beta simultaneously. V12 in AS3 has been tested and used extensively. You are strongly encouraged to start using v12 as it has many new features and benefits.

 

As for your issue, it is very important that all features of the platform work as intended. If you can provide a file that isolates the unexpected behavior you are experiencing it will go a long way towards allowing us to

 

1) explain why it is happening

2) fix any bugs that you may have uncovered in your very unique situation

 

I'm a bit confused by how you say that after you append new tweens the timeline needs to be "restarted". Are you referring to using the restart() method specifically which will make the timeline play again from the beginning or do you mean that you need to invoke a play().

 

It would be best if you can provide a test file that clearly illustrates the problems you are experiencing so that we can resolve this issue for you in a timely fashion.

 

Best,

 

-c

Link to comment
Share on other sites

When you create a TimelineMax, it has its startTime be whatever the current global time currently is (unless you give it a delay which would of course get factored in). So let's say you create a TimelineMax when your app begins (time:0) and populate it with 5 seconds of tweens and then it runs and completes. So its startTime would be 0 and it'd finish at 5-seconds. Then 30 seconds later (now at a global time of 35 seconds), you append() a tween to that timeline. Where would you expect that tween to be placed in relation to the last tween in that TimelineMax? append() implies that it would get scheduled at the very end of that timeline, right after the last tween and that's exactly how it works. But think about where that is in relation to the global time - it's actually in the past. Remember, the TimelineMax finished at exactly 5-seconds, so if we append() a 2-second tween, that means it would end at 7-seconds, but the global playhead is currently at 35 seconds! Therefore, as soon as the tween renders, it will be at its end.

 

If you want the newly appended tween to play as though it is just beginning, there are only 2 options:

  1. MOVE the startTime of the whole TimelineMax (basically like picking it up and moving it forward) so that the global playhead aligns exactly with the end of the TimelineMax (well, what was previously the end before you appended the new tween) which is where that timeline's playhead was stuck (a playhead can never go past the end of a timeline). To do this, you can simply call something like myTimeline.seek(myTimeline.time());
    -OR-
  2. Insert the tween at the correct time such that you include that 30-second gap that elapsed. So in our example, instead of appending (which would make the tween start at the 5-second spot in the timeline), you insert() at the specified time. You can actually use the timeline's "rawTime()" to get its uncapped time (like if the playhead wasn't limited to never go past the end). Like myTimeline.insert(myTween, myTimeline.rawTime()); and then play() just to make sure it kicks into action after it has retired.

As Carl said, it would be super helpful to see an example FLA that we can publish on our end to see exactly what's going on in your file. I'm sure we can get it solved for you. We just need some help to see what you're up against.

Link to comment
Share on other sites

When you create a TimelineMax, it has its startTime be whatever the current global time currently is (unless you give it a delay which would of course get factored in). So let's say you create a TimelineMax when your app begins (time:0) and populate it with 5 seconds of tweens and then it runs and completes. So its startTime would be 0 and it'd finish at 5-seconds. Then 30 seconds later (now at a global time of 35 seconds), you append() a tween to that timeline. Where would you expect that tween to be placed in relation to the last tween in that TimelineMax? append() implies that it would get scheduled at the very end of that timeline, right after the last tween and that's exactly how it works. But think about where that is in relation to the global time - it's actually in the past. Remember, the TimelineMax finished at exactly 5-seconds, so if we append() a 2-second tween, that means it would end at 7-seconds, but the global playhead is currently at 35 seconds! Therefore, as soon as the tween renders, it will be at its end.

 

If you want the newly appended tween to play as though it is just beginning, there are only 2 options:

  1. MOVE the startTime of the whole TimelineMax (basically like picking it up and moving it forward) so that the global playhead aligns exactly with the end of the TimelineMax (well, what was previously the end before you appended the new tween) which is where that timeline's playhead was stuck (a playhead can never go past the end of a timeline). To do this, you can simply call something like myTimeline.seek(myTimeline.time());
    -OR-
  2. Insert the tween at the correct time such that you include that 30-second gap that elapsed. So in our example, instead of appending (which would make the tween start at the 5-second spot in the timeline), you insert() at the specified time. You can actually use the timeline's "rawTime()" to get its uncapped time (like if the playhead wasn't limited to never go past the end). Like myTimeline.insert(myTween, myTimeline.rawTime()); and then play() just to make sure it kicks into action after it has retired.

As Carl said, it would be super helpful to see an example FLA that we can publish on our end to see exactly what's going on in your file. I'm sure we can get it solved for you. We just need some help to see what you're up against.

 

But Carl's example in Reply #2 works without setting timeline's time.

He wrote:

" Regardless of whether or not the timeline is done playing, the newly added tweens will always play at the right time without forcing the timeline to play()"

 

I didn't mention one thing, and that is that my timeline has autoRemoveChildren=true.

I think Carl's example works because autoRemoveChildren=false;

 

myTimeline.seek(myTimeline.time()) is working for me, but I will test it more so that I can be sure.

 

Thanks for explanation.

Link to comment
Share on other sites

Yep, we actually implemented code in more recent versions of TimelineLite/Max that will automatically make that adjustment for you in certain situations where it seems to make the most sense - I just wanted you to understand the concept.

 

And yes, if autoRemoveChildren is true, that'll remove child tweens when they finish (when the virtual playhead passes their ending spot), so it would make sense that the [old] tweens wouldn't play the 2nd time around.

 

Let us know if you need anything else.

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