Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex 4 - Programmatically set a button click handler function to null

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

like image 553
Jason Avatar asked Jul 24 '26 06:07

Jason


1 Answers

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.

like image 154
rfunduk Avatar answered Jul 27 '26 22:07

rfunduk