Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
pierrreke

Multiple timelineMax on same target

Recommended Posts

Hi everyone,

 

I'm new on this forum, first thanks to Greensock for the awesome library.

But... I have a serious problem with the timelineMax. What i want to do:

 

- declare 2 or more timelineMax's with tweens on the same target

- calls multiple times in a short time the gotoAndStop method on a (random) timeline.

- the latest gotoAndStop must overwrite every other tweens or timelines.

 

The problem is that mostly the latest timelineMax.gotoAndStop is not set.

 

You can see a simple example of my problem in my attachment.

Just publish the fla with and without the comments on line 22 to 32.

 

The result should by the same... but it isn't.

 

Can someone help me with that? (I'm sorry for my bad English)

 

Thank you,

Pieter

example.zip

Link to post
Share on other sites

There's a performance optimization in the timeline (and tween) classes that cause them to skip rendering if the instance is already at that particular time. For example, if your timeline1 renders at time 20 and then you gotoAndStop(20) again, it thinks "ummm, I'm already at 20 now, so I shouldn't waste CPU resources calculating all the values again and rendering them". In your example, you were doing a gotoAndStop(12) and then having another timeline/tween alter the values, and then doing another gotoAndStop(12), so the optimization kicked in and ignored the request to render things where they were supposed to already be. See what I mean? Believe it or not, you're the first person (that I can remember) who has come up with a scenario where this [optimized] behavior isn't the desired one. In 99.999%+ of the use cases, the performance optimization delivers the most desirable results.

 

The solution is simple: if the time is identical to the already-rendered one, just add or subtract a little bit right before you do your gotoAndStop(), like this:

 

//v12 code, not v11

private function animationOne(frame:int):void {
   if (timeline1.time() == frame) {
       var offset:Number = (frame == 0) ? 0.0001 : -0.0001;
       timeline1.seek( frame + offset );
   }
   timeline1.gotoAndStop(frame);
}

  • Like 1
Link to post
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.

×