Skip to main content
arindam_mojumder
Participant
December 22, 2008
Question

removeEventListener is not working on if/else condition

  • December 22, 2008
  • 2 replies
  • 482 views
Hello All,

It is very ridiculous that I can't remove a simple listener method :). I think this is a common problem
When I am using removeEventListener manually, i.e outside the condition its working fine, but whenever I am using it inside the if/else condition it is adding the listener in "true" mode but not removing in the "false" mode.


here is my code:

if (proAlign == true) {

trace("align Option = " + proAlign + " -- " + "this is true part");

centerAlignButton.buttonMode=true;
bookPocketAlignButton.buttonMode=true;

centerAlignButton.addEventListener(MouseEvent.CLICK,centreAlign);
bookPocketAlignButton.addEventListener(MouseEvent.CLICK,pocketAlign);

} else {
centerAlignButton.removeEventListener(MouseEvent.CLICK,centreAlign);
bookPocketAlignButton.removeEventListener(MouseEvent.CLICK,pocketAlign);

centerAlignButton.buttonMode=false;
bookPocketAlignButton.buttonMode=false;

}
This topic has been closed for replies.

2 replies

Participating Frequently
January 5, 2009
I suggest tracing proAlign's value just prior to the if (proAlign) {...

'Cause your code should work, unless the handler "centreAlign" should read "centerAlign".
Known Participant
December 22, 2008
have you tried,
} else if(proAlign == false) {