Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
American horizon

There are something strange while attempting to calculate coordinates of an MC during a tween

Recommended Posts

Hi, i noted a strange phenomenon that can change my idea about how tweenmax works


I do a simple example


TweenMax.to(MC, 1, {y: 1000, onProgress: checkY()})

function checkY():void
  trace (MC.y)



Well, the trace return me always the same initial MC's Y coordinate, and not the updated position... Why ?

Link to comment
Share on other sites

I assume you meant "onUpdate" instead of "onProgress", right?


And the reason you're only seeing the initial value is because you put "()" after your function reference which calls it immediately (that's just how ActionScript works - it has nothing to do with TweenMax).



TweenMax.to(MC, 1, {y: 1000, onProgress: checkY()})


TweenMax.to(MC, 1, {y: 1000, onUpdate: checkY})

Link to comment
Share on other sites

Umh, for a personal culture, what the difference from calling a function with brackets and without it?

Link to comment
Share on other sites

When you use the parenthesis() it tells the function to run immediately.


The reason why you don't use the parenthesis inside the tween is because you are just passing in a reference to the name of the function you want TweenLite to use when the tween is running.


Does that help?



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.