views:

1194

answers:

2

I am looking for a way to programmatically dissassoicate the click handler function from a button on my mxml component through actionscript code.

Something like what older actionscript let you do,

mybutton.click = null;

Thanks in advance

A: 

Hi Jason,

Not sure if I understand this correctly, but you can remove an event listener or better yet not add one for the click event at all.

In case you are trying to "disable" clicks without disabling the button, you might just want to use the same skin for the various click states of the button so there won't be any visual indication of a click.

HTH, Sri

Srirangan
http://www.flexwizz.com/2008/03/23/magic-lines-of-code/http://blog.flexexamples.com/2008/08/20/determining-if-an-item-is-listening-for-a-specific-event/
Srirangan
+2  A: 

If you have the function that was registered as the listener:

mybutton.removeEventListener( 'click', theFunction );

If you don't... well, consider reorganizing the code? You might also be able to add another handler something like this:

mybutton.addEventListener( 'click', function( e:Event ):void {
  e.stopImmediatePropagation();
  return false;
}, false, 1 );

Which might prevent further handlers from running (the 1 at the end is the priority)... Hard to say sometimes with flex.

thenduks
Thanks thenduks, that is exactly what I was looking for.
Jason W
Glad to be able to help Jason.
thenduks