I don’t know why but i am having trouble getting my head round event dispatching.
Take this for example.
someClass():Void{
this.addEventListener("onChange",someObj);
}
Am i right in assuming this means that someClass is listening for an onChange event and when it gets it, it is then going to fire the onChange method on someObj?
Thanks, Kohan.
Addendum:
lo = new Object();
lo.click = function(evt){
trace(evt.target.label + " clicked");
}
button1.addEventListener("click", lo);
Hopefully from here which i have found on this site: http://www.webwasp.co.uk/tutorials/keywords/addEventListener.php
You can see how i came to this assumption. lo is an Object, not a method, am i correct?
You got it wrong:
Will add an event listener to this’s onChange listeners list, which – when the event is fired – will call the someObj method!
You need to pass the method itself as the parameter. So, use:
*BTW, it is better not to use the “onChange” string itself, but rather use constants (such as Event.ENTER_FRAME) which hold those strings.