Share Posted August 17, 2012 Hi, just wanted to let you know that it seems that clear() on a timeline does not remove eventCallbacks. It doesn't matter if they are set by the constructor or afterwards with eventCallback('eventtype', function) I'm using latest Chrome and the latest TweenMax & TimelineMax JS versions on Windows 8 (shouldn't matter) just try the following: var tl = new TimelineMax({onComplete: function() {console.log('complete');}}); tl.eventCallback('onComplete'); //returns function tl.eventCallback('onReverseComplete', function() {console.log('reversed');}); tl.clear(); tl.eventCallback('onReverseComplete'); // still there tl.eventCallback('onComplete'); // still there Although eventCallbacks get not killed, the containing tweens and timelines are removed and the totalDuration is 0 afterwards. Would be nice if someone could confirm that! Link to comment Share on other sites More sharing options...
Share Posted August 17, 2012 Yes, that is correct (and intentional) - clear() is only supposed to remove all the child tweens/timelines, it is not supposed to destroy the callbacks associated with the timeline itself. Typically, when someone adds an onComplete/onUpdate/onStart/onRepeat to a timeline instance, they want it to happen regardless of specific child tweens that exist inside the timeline, so it would be pretty annoying if clear() wiped out all their event callbacks and they had to re-add them again. You can, of course, delete callbacks by using the eventCallback() method and setting the callback to null, like: myAnimation.eventCallback("onComplete", null); myAnimation.eventCallback("onUpdate", null); myAnimation.eventCallback("onStart", null); 2 Link to comment Share on other sites More sharing options...
Author Share Posted August 17, 2012 Thank you for your quick response! Just read the docs before and I think I was kind of confused because it says 'Empties the timeline of all ... callbacks'. But now I understand that custom callbacks are meant and not the internal ones (complete, reverseComplete etc.). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now