Jump to content

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

onComplete firing when overwriting

Recommended Posts

I'm using the JS version of greensock and I have an issue with an onComplete function being called when overwriting a tween and creating a new timelinelite instance.


So, effectively I create a number of tweens and add them to an array that I then parse into insertMultiple method of a TimelineLite instance.


I've tried killing the timelinelite timeline before creating a new one, but the onComplete function is still called. How do I prevent the onComplete function being called when overwriting/creating a new instance of the timelinelite?


for(var x = 0; x < 12; x++) {
  if(has_children) {
m = c.getChildAt(x);
  } else {
m = new createjs.Text();
m.x = (20*x);
  m.y = 0;
  m.alpha = 1;
  m.text = multiple * (x+1);
  ta.push(TweenMax.from(m,0.5,{y:20,alpha:0,ease:Back.easeOut, overwrite:1}));
 if(this._tl != null)
 this._tl = new TimelineLite({onComplete:function(){console.log("Hi");root._msg1.visible = root._msg2.visible = true; root._msg1.text("Here is the pattern for x times table.");root._msg2.text("This can be carried on to give more multiples of x")}});

Link to comment
Share on other sites

I can't seem to reproduce that problem - could you post your HTML page with only the necessary code to reproduce the problem? I'd really like to see the onComplete getting called even after kill() has been called on that TimelineLite instance.


Also, are you using the latest version of the GSAP files?

Link to comment
Share on other sites



If you click one of the 4 buttons then click another, the onComplete event is immediately called resulting in the message boxes appearing. They should only appear once the tween has completed.


Interestingly, if the same button is pressed the tweens restart, but the onComplete event doesn't fire.


I'm using the GSAP that I downloaded a few days ago.

Link to comment
Share on other sites

There's a lot of code in there, but it looks like you're not calling kill() at all. I added a console.log() and this._tl is always undefined, so your conditional logic is always skipping the kill() call. I didn't have time to look at how you structured everything, but I suspect it's an issue of what "this" refers to, like maybe you're creating a new instance each time and you're not referencing the old one correctly. See what I mean?


I ran a bunch of tests on my end and confirmed that the onComplete never gets called if you kill() a TimelineLite or TimelineMax (unless I missed something sneaky).

Link to comment
Share on other sites

Ahh, that's the problem, it's a scoping issue for this. Because the showMultiple function is tied to a button click, this refers to the button and not the class! Silly me!


Thanks for your time, I have another question but will create a new topic for that.

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.