Jump to content
Search Community

TimelineMax.totalDuration is not equal what I insert

kittichai test
Moderator Tag

Recommended Posts

I create a timeline and its totalDuration does not equal the duration of the Tween inside it.

 

Here's cut of my code, let's call this function a();

 

private function a():void {
 _timeline = new TimelineMax({paused:true, onComplete:onCompleteFunction});
 var newTimeline:TimelineMax = new TimelineMax({paused:true});
 var tween3:TweenMax = new TweenMax(mainStageScrollRect, 5.3, {x:pageTo.coreDisplay.displayObject.x, paused:true});
 newTimeline.insert(tween3);
 tween3.paused = false;
 _timeline.insert(newTimeline, 0);
 newTimeline.paused = false;
 trace("-----------------------------------");
 trace(_timeline.totalDuration);
 trace(newTimeline.totalDuration);
} 

The result when I run function a() 3 times are as follow:

-----------------------------------
5.3
5.3
-----------------------------------
12.143
12.143
-----------------------------------
91.938
91.938

 

the first time i call function a(), the _timeline.totalDuration appears to be 5.3 perfectly. But, when I call it for second time, the totalDuration increse to some random number and keep increasing to some random number. When I check, its totalDuration will equal its startTime. I understand that startTime of newly create Timeline will be equal to the rootTimeline's current clock, but should it effect totalDuration? How can I get the real totalDuration of what I insert in?

 

This is really important to me to get the exact totalDuration because my program architecture does not allow me to get it otherwise.

Link to comment
Share on other sites

The issue had to do with the fact that you were pausing the tweens before inserting them into the timeline. There's no reason to do that if you're going to unpause it on that same frame (before the next ENTER_FRAME event runs) but I did just post an update to the tweening platform that fixes the issue even if you insert paused tweens/timelines into a timeline. http://www.TweenLite.com. Thanks for letting me know about this.

Link to comment
Share on other sites

I pause all TweenMax at constructor to make sure that all Tween will not run before inserted to Timeline. Is there other way I can do to make sure it won't happen? I am concern that if I create lots of Tween before insert to Timeline, some may run before Timeline can manage them. It's irritating having to pause in every constructor. If u have best practice, please suggest.

 

Anyway, thanks for the quick fix!

Link to comment
Share on other sites

That's one of the nice things about TweenLite/Max - the tweens are perfectly synchronized. You'd run into that problem with most other engines, but even if you loop through and create 100,000 tweens on a single frame and it takes 5 seconds to create them all, they will all start at exactly the same time. They will NOT start running until the next ENTER_FRAME event, nor will their start times drift. So save yourself the headache of doing all that pausing/unpausing. :)

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