Jump to content
Search Community

Synching help

Popinjay test
Moderator Tag

Recommended Posts

I have two tweens:

 

                    TweenMax.fromTo(gameBoard.piecesOGrid[sx][sy].amoeba.body, 1 * animSpeedFactor, {frame: 436}, {frame: 477, onComplete: move_animation_completedB, onCompleteParams: [gameBoard.piecesOGrid[sx][sy]]});
                    TweenMax.fromTo(gameBoard.piecesOGrid[sx][sy].amoeba, 1 * animSpeedFactor, {frame: 517}, {frame: 559});
 

The problem is, even though both are set to run the same amount of time one of them completes slightly before the other causing a "blinking" effect.  As you might notice the animations are not exactly the same number of frames.  Also the clips are nested in each other---one clip is the body and the other the eyes, if that makes any difference.  Is there a way to make sure that they synchronize exactly?

 

I was trying the timeLineMax but when I put the tweens on to that they run consecutively, not together (which is obviously how timeline is meant to work, but that doesn't help me here).

 

Been trying to solve this for a couple of days---although figuring out the source of the problem took a large portion of this time.  Any help appreciated.

 

Popinjay

Link to comment
Share on other sites

Yeah, its sort of an awkward if not impossible situation if you want 2 frame tweens with different amounts of frames to stay perfectly in sync. Its not like you can have 1 tween wait for half a frame here and there to make up the difference. 

 

I see that tween 1 has 42 frames, tween2 has 41 frames (thanks for pointing that out) 

 

Have you tried just duplicating a frame in the short tween to make up for the discrepancy or deleting a frame from the long tween? Is there difference less noticeable than the blink you are getting?

 

Also you could delay the start of the short tween and give it a shorter duration to force it to end at the same time as the long tween.

 

The fact that 1 clip is nested inside another shouldn't be a problem as movieclips can play totally independently from their parents.

 

Another note, when using TimelineMax you can have tweens start at any time, they don't have to be 1 after the other. something like this will have both tweens starting at the same time

 

Using the latest version of GSAP

 

 

var tl:TimelineMax = new TimelineMax()
tl.to(mc, 1, {left:20})
  .to(mc2, 1, {left:20}, 0);
 

 

 

In the second tween the 0 is the starting time (position) of the tween. Both tweens will start at the same time

 

More info in the v12 Timeline docs

http://api.greensock.com/as/com/greensock/TimelineLite.html#to()

 

Another thing that comes to mind is that Tweens by default have eases applied to them. Perhaps some rounding that happens due to the ease is forcing on of the tweens to appear in its final state before its time.

 

For instance for the last handful of updates of your tween, perhaps that frame value is something like 

 

556.2

556.6

556.8

556.9

556.93

556.957

 

Since flash can't render frame  556.2, maybe its forced to render frame 557 before the duration of the tween expires. 

 

Try throwing an ease:Linear.easeNone on there and see if it makes any difference. 

Link to comment
Share on other sites

If I understand the description correctly, the problem simply has to do with rounding. Remember, frames can only be whole numbers, thus the FramePlugin rounds the value for you. Imagine going from 1 to 10 over the course of 5 seconds - when the value is 2.4145, it'd round to 2, but when it is 2.537, it'd round to 3. See what I mean? So if you've got 2 tweens that are going a different distance (in terms of frames), they're going to snap at different points along the way. 

 

For example, if one tween has to go 3 frames and another has to go 300 frames over the same course of time, the first one will reach the final frame when it's 0.83% done whereas the 300-frame one will reach the final frame when it's 99.8% done. 

 

If your goal is to have the final frame change at the same time, you could just tween to one frame less and then use an onComplete on both tweens that jumps to the final frame.

 

And by the way, timelines are NOT just for sequencing - you can have the tweens overlap as much as you want, or have 1000 of them running concurrently - whatever. Very flexible. 

Link to comment
Share on other sites

Thanks for the detailed responses.

 

I did try using one frame less before posting.  That is why I thought nesting might be an issue.  When I did that I kept getting another weird problem (part of the animation repeats for no apparent reason I can see).  When I first started writing this program I didn't know about GS.  I am now swapping tweenMax for the animations so that I can easily adjust animation speed on the fly, but since I didn't plan it that way from the beginning I'm running into problems when trying to change code I wrote more than a year ago.

 

Anyway, I will try some of the solutions here.  Maybe changing the easng will work.

 

Pop

Link to comment
Share on other sites

Update:  While just starting a frame later didn't work, using linear noease in conjunction with moving up a fame did work.  I don't know why simply having the same number of frames didn't fix it---but thanks for the help.  I didn't know easing was applied by default.

 

I just thought I would say thanks.  I know lots of times people just disappear without ever saying if their problems is solved or not.

 

Pop

 

 

Thanks for the detailed responses.

 

I did try using one frame less before posting.  That is why I thought nesting might be an issue.  When I did that I kept getting another weird problem (part of the animation repeats for no apparent reason I can see).  When I first started writing this program I didn't know about GS.  I am now swapping tweenMax for the animations so that I can easily adjust animation speed on the fly, but since I didn't plan it that way from the beginning I'm running into problems when trying to change code I wrote more than a year ago.

 

Anyway, I will try some of the solutions here.  Maybe changing the easng will work.

 

Pop

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