I have created an image id="myImage" in flex with a click event, i.e. click="myFunction(e)"
In myFunction I want to remove or disable the click event in the event handler (ActionScript). I have tried
myImage.removeEventListener('click', myFunction, false) ;
myImage.removeEventListener( MouseEvent.CLICK, myFunction, true);
myImage.removeEventListener( MouseEvent.CLICK, myFunction, false);
myImage.click = NULL; isn't allowed...;-(
Can you help?
I think the problem may be that the mxml click notation makes a handler on your behalf and you supply the body (think anonymous function). So you supply the body of the click handler which calls your handler, but your handler is not actually the name of the click handler itself.
If you want to be able to remove the function, explicitly create a handler using addEventListener rather than the mxml convenience mechanism, or alternatively create a flag for the handler to check to see if it should do anything or not.