Is there a way to overwrite the property of a tween? If I write
el.set('tween', {duration: ‘long’, onComplete: callback});
and then
el.set('tween', {duration: 200, onComplete: secondcallback });
I can’t replace the old property (callback is triggered again)
Is possible to solve this problem without the creation of a new Fx.Tween everytime?
Each time you set onComplete
on the same instance, callbacks are pushed and associated with the same 'complete' event and each callback will be called after the event is fired.
To 'replace' the onComplete
callback, you could use removeEvent
, i.e.
el.set('tween', {duration: ‘long’, onComplete: callback});
//and then...
el.get('tween')
.removeEvent('complete', callback)
.addEvent('complete', secondcallback);
demo => http://jsfiddle.net/NNzQ7/