Jump to content


Tween Time Accuracy

Recommended Posts

Hi All,


I'm creating a game and I'm having some issues with timing accuracy of TweenMax. Basically, I have a vehicle moving between two points using the following code:


vehicleTweener = new TweenMax(vehicleMovieClip, moveData['journeyTime'], {x:goTo['x'], y:goTo['y'], ease:Linear.easeNone, onComplete:checkForArrival});


moveData['journeyTime'] is in seconds, and I've turned off easing.


The vehicle moves and arrives where it should, so no issues there. However, I'm having some issues with the accuracy of the tween. It seems to be moving a little too fast as it will usually arrive about half a second before it should.


Whilst that doesn't sound like a big deal, as the vehicle moves from point to point this inaccuracy starts to add up. Just wondering if there's a simple fix to this? I know timers are a tricky topic, but I was kinda hoping I could get away without having to come back to the server too often to check/validate vehicle position.


Thanks in advance...

Link to comment
Share on other sites

A half of a second is a BIG deal. It absolutely, positively should not be arriving early and I'm very curious to see an example FLA that I can publish to see proof that this is happening. I can't imagine how it could, given the timing logic in the tweening engine, but maybe you stumbled across some odd bug. Can you share how exactly you're tracking whether or not it's "early"? Like what are you comparing it to? Are you using a getTime()? A sample FLA would be super helpful (please only include the absolutely essential code and strip out anything extra).

Link to comment
Share on other sites

Thanks for the quick reply :)


I've done a few more tests, and it looks like it was caused by my coding, not TweenMax. I was using a tween to centre on the vehicle before it starts moving, and setting up a tween to get the stage to track with the vehicle.


For some reason the tracking value was overriding the vehicle value. This always a little bit less to give it time to move the stage before the vehicle started moving. Anyway, I've set up a function to run when the tween completes and it's now showing to within 0.04 seconds which sounds about right I think.

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.