No, you don't need to remove the listener twice in that situation.
You need to remove multiple listeners in two situations:
- if you add two event listeners with different listener functions:
txtField.addEventlistener( Event.CHANGE, changeCb, false, 0, true );
txtField.addEventlistener( Event.CHANGE, changeCb2, false, 0, true );
- if you set one event to fire in the capturing phase:
txtField.addEventlistener( Event.CHANGE, changeCb, false, 0, true );
txtField.addEventlistener( Event.CHANGE, changeCb, true, 0, true );
So you only need to remove events that are registered in a different manner from each other.
You can't get a count of the event listeners with what's provided out of the box in Flex, but you can check if it has an event listener for a specific type of event using the hasEventListener(type)
.
However, because the source code if provided, you can "Monkey patch" the UIComponent or the FlexSprite class to add this functionality, as explained in this blog. Actually, you don't even have to do it. Code is provided in the example. Pretty cool.