Question
removeEventListener is not working on if/else condition
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;
}
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;
}