Ok, that makes sense and is how I originally expected 1.2 to act, so it's good to know that's how it's working now.

I do think this one is a bug though - I started clearing the event before I do my element.set('tween') statements, since I was previously assuming that that would clear the event. But I'm getting an error if I clear the event twice - this block of code will reproduce it:

    $('item').set('tween',{'onComplete':function(){}});
    $('item').get('tween').removeEvents('complete');
    $('item').get('tween').removeEvents('complete');

In firebug if I trace it, the first removeEvents() doesn't actually remove the event, it sets it to 'undefined'. The second removeEvents() finds the 'complete' event in this.$events but it eventually throws an error because it still treats it like it's a proper function.

Tracing it in firebug, line 98 of Class.Extras.js has fns as 'undefined' for the second remove events. fns.length returns 1. It then calls this.removeEvent('complete','undefined') which throws an error in removeEvent() on line 81 of 'fn is undefined'

On Dec 6, 2010, at 10:07 AM, Dimitar Christoff wrote:

In 1.2, the DOM element slides to 500, alerts 'tween_1 complete',
slides to 100, and alerts 'tween 2 complete.' In 1.3, the DOM element
slides to 500, alerts 'tween_1 complete', slides to 100, alerts
'tween_1 complete' then alerts 'tween_2 complete' and then gets stuck
in a loop. It appears that when I'm calling $('item').set('tween') it is appending the onComplete function instead of replacing it. Is this
intended behavior or is it a bug?


It's not a bug. You need to remove the old onComplete event first, else, it's going to stack them up - you can have unlimited callbacks per event,
it's not 1 size fits all (in the style of element.onclick = ...

This applies to element events as well.

Just do this.removeEvents("complete") as the last line of the first
complete event before you add the new one (making sure `this` is bound
to the Fx instance)

else, you can do
el.get("tween").removeEvents("complete").addEvent("complete",...); as
the second tween

Regards,
--
Dimitar Christoff <[email protected]>

blog: http://fragged.org/  twitter: @D_mitar


--
Jon Baker

"This e-mail has been transmitted using 100% recycled electrons."

Reply via email to