No, you do not need to remove the listener twice in this situation.
You need to remove multiple listeners in two situations:
- if you add two event listeners with different listening functions:
txtField.addEventlistener (Event.CHANGE, changeCb, false, 0, true);
txtField.addEventlistener (Event.CHANGE, changeCb2, false, 0, true);
- if you set one event to record at the capture stage:
txtField.addEventlistener (Event.CHANGE, changeCb, false, 0, true);
txtField.addEventlistener (Event.CHANGE, changeCb, true, 0, true);
Therefore, you only need to delete events registered in another way.
You cannot count the number of event listeners with what is provided in a block in Flex, but you can check if it has an event listener for a specific type of event using hasEventListener(type) .
However, since the source code, if provided, you can "Monkey patch" for the UIComponent or FlexSprite class to add this functionality, as described in this blog . In fact, you do not even need to do this. The code is given in the example. Pretty awesome.
source share