Javascript dispatchEvent
Posted
by xpepermint
on Stack Overflow
See other posts from Stack Overflow
or by xpepermint
Published on 2010-02-13T00:00:27Z
Indexed on
2010/06/17
2:32 UTC
Read the original article
Hit count: 311
Hey... I'm using Flash a lot and my classes uses EventDispatcher class which allowes me to define custom events of a class. How can I do this in javascript.
I would like to do something like this:
var MyClass = function() {
};
MyClass.prototype = {
test : function() {
dispatchEvent('ON_TEST');
}
};
var mc = new MyClass();
mc.addEventListener('ON_TEST', handler);
function handler() { alert('working...') }
How is this posible with Javascript?
© Stack Overflow or respective owner