Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
Owen Corso

TweenLite onComplete fires function immediately [SOLVED]

Recommended Posts

Hello there,


First, TweenLite is the fastest tweener ever GREAT JOB! i use your delightful library exclusively. Thank you so much!


Second, sometimes when using TweenLite, my onComplete functions fire immediately, ie:

TweenLite.to(peopleContainer.peopleHdr, .5, {y: (peopleContainer.peopleHdr.y+75), alpha:1, overwrite:3, onComplete: toggleVisibility()});


this statement is unfortunately toggling the visibility before the tween even starts :(

in reading the forums, it seems there is a scoping issue in Actionscript 2 but explicitly not so for AS3 and as this is AS3, i wanted to reach out and check with you.


Thanks again for the great free fast code! :mrgreen:


~Owen Corso


Link to comment
Share on other sites

Remove the () from function name so it doesn't fire right away.


TweenLite.to(peopleContainer.peopleHdr, .5, {y: (peopleContainer.peopleHdr.y+75), alpha:1, overwrite:3, onComplete: toggleVisibility});



TweenLite.to(peopleContainer.peopleHdr, .5, {y: (peopleContainer.peopleHdr.y+75), alpha:1, overwrite:3, onComplete: toggleVisibility()});

  • Like 1
Link to comment
Share on other sites

  • 2 years later...



What if you want to pass a var through the onComplete:myFunction(myVar);


I am having the same issue but if I remove the () then my var wont go thru.

Link to comment
Share on other sites

Think of myfunction as a variable of type Function, with () as the bit that causes the function to actually be called.


Parameters can be passed using onCompleteParams

TweenLite.to(target, duration, {onComplete:myFunction, onCompleteParams:[myVar]});

  • onComplete : Function A function that should be called when the tween has finished
  • onCompleteParams : Array An Array of parameters to pass the onComplete function

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I know this was last addressed a while ago but I'm still getting this issue even using no '()' on my onComplete and passing params correctly. I'm getting a cross fade but also a blink of the first asset fading out.  Shouldn't the onComplete function not fire until the first animation is done?  Thanks.

TweenMax.to(container, .5, {alpha:0, ease:Linear.easeNone, onComplete:addNewSection, onCompleteParams:[sectionName]});
private function addNewSection(sectionName:String):void
switch (sectionName) 
case 'menuGuide':
//other cases....
TweenMax.to(container, .7, {alpha:1, ease:Global.EASE_TYPE1});
Link to comment
Share on other sites

Hi Flabbygums,


It is difficult to know why your asset is blinking by just looking at the code.

Please provide a reduced test case that we can test. Please keep it simple with only the bare minimum amount of code and assets necessary to recreate the issue.

Please zip your Fla before attaching.


Also, in the future it is better to create a new thread than to revive one marked as [sOLVED] from 2 years ago. Thanks

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.