Jump to content
GreenSock

Ghelle

onComplete not firing when using updateTo on onUpdate

Recommended Posts

onComplete not firing when using updateTo on onUpdate. if I remove updateTo line onComplete is triggered as it should.

private function fingerLoop():void 
{
  TweenMax.to(finger, 1, { x:gotoPlanet.x, y:gotoPlanet.y, onComplete:fingerLoop, onUpdate:moveFinger, onUpdateParams:["{self}", gotoPlanet] });
}

private function moveFinger(tween, gotoPlanet):void 
{
  tween.updateTo({x:gotoPlanet.x, y:gotoPlanet.y}, false);
}
Link to comment
Share on other sites

We recommend that you do not use updateTo() on values that are constantly changing. http://greensock.com/asdocs/com/greensock/TweenMax.html#updateTo()

 

Instead you should use DynamicPropsPlugin http://greensock.com/asdocs/com/greensock/plugins/DynamicPropsPlugin.html which is a bonus plugin for Club GreenSock memebers. You can learn more here http://greensock.com/club/ (choose "Flash" from menu in "What you Get" section).

 

I verified that onComplete will work with the following code using DynamicPropsPlugin

 

import com.greensock.TweenLite; 
import com.greensock.plugins.*; 
TweenPlugin.activate([DynamicPropsPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
TweenLite.to(mc, 1, {dynamicProps:{x:getMouseX, y:getMouseY}, onComplete:someFunction});
    
function getMouseX():Number {
    return this.mouseX;
}
function getMouseY():Number {
        return this.mouseY;
} 


function someFunction() {
trace("done");
}
 
So I'm sure it will work for you. Just use gotoPlanet.x instead of mouse coordinates.
 
I also did see the code you provided did not fire the onComplete as you explained. I am not sure if this is a bug (it might be, but we won't be able to verify that right away) or whether its the reason we do not recommend using updateTo() in this fashion. Again, updateTo() is intended only to be used sparingly and DynamicProps was created exactly for this type of scenario.
Link to comment
Share on other sites

Got it. Seems like I was trying to make free version of DynamicPropsPlugin. :)

 

Thank you @Carl

Link to comment
Share on other sites

P.S. Thanks for great libraries!

 

I think I'll join the Club GreenSock. You got more good staff there.

Link to comment
Share on other sites

  • 9 months later...

I had the same problem. I was using updateTo on values that were constantly changing and my onComplete didn't fire. I fixed it by giving my tween a variable name and then tweening it's time like this:

 

TweenMax.to(myTween,duration,{time:duration,onComplete:myOnComplete});

 

I may still join Club GreenSock at some point though. Quick question, if I buy a single developer annual Business Green membership for $150 and decide to upgrade it to a permanent license within that same year, can I pay $600 instead of $750?

Link to comment
Share on other sites

Hi BladePoint,

 

Yes, if you upgrade, you only need to pay the difference between the 2 memberships (600)

 

Carl

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