With this function you can pass an object when adding and get it in the listener. the problem is that you have an anonymous function as an eventlistener, and in actionscript you cannot remove an anonymous listener. dunno bout js.
addEvent:function(object,type,listener,param) { if(object.addEventListener) object.addEventListener(type, function(e){ listener(object, e, param);}, false ); else if(object.attachEvent) object.attachEvent('on'+type, function(e){ e = getEvent(e); listener(object, e, param);}); }, getEvent:function(e) { if(!e) e = window.event; // || event if(e.srcElement) e.target = e.srcElement; return e; }, removeEvent:function(object,type,listener) { if(object.removeEventListener) object.removeEventListener(type, listener, false); else object.detachEvent('on'+type, listener); } var div = document.getElementById('noobsafediv'); var div2 = document.getElementById('noobsafediv2'); addEvent(div,'mouseover',mouseover,['astring',111,div2]); function mouseover(object,e,param) { console.log(object,e,param); }
its my structure and i call it jNoob.
Anas Mar 16 '11 at 15:05 2011-03-16 15:05
source share