How can I set-up an event handler like on some of the macromedia components.
ie.. a user defined function recieves a callback from the component when clicked.
I found the code below but I not sure how to get it working with a new component (I have listed what I have tried to this point)
ActionScript Code:
//put this inside the component
ComponentClass.prototype.setClickHandler = function(chng,obj) {
this.handlerObj = (arguments.length<2) ? this._parent : obj;
this.clickHandler = chng;
};
ComponentClass.prototype.executeCallBack = function() {
this.handlerObj[this.clickHandler](this);
};
//added this code to main timeline
componentInstanceName.setClickHandler("myClick", _root);
function myClick(component) {
trace (component);
}
I know I missing some stuff but not sure what...