I'm using Flash a lot and my classes uses EventDispatcher
class which allows 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 possible with JavaScript?