Hi,
I'm having what seems to be an all too common problem with modules. I have
split my app into 3 separate modules, and listeners created in 1 instance of
a module get duplicated the second time a module loads. Events defined in
mxml are a big problem
<mx:ButtonBar id="listButtons" dataProvider="{ListData}"
itemClick="clickHandler(event)" />
the second time a module is loaded that contains this buttonbar that
clickHandler function will fire twice, and 3 times for the 3rd load. so i
attempted to remove listeners, and only add listeners if they are not
already there so:
private function init():void
{
if(!listButtons.hasEventListener(ItemClickEvent.ITEM_CLICK))
listButtons.addEventListener(ItemClickEvent.ITEM_CLICK,clickHandler,false,0,true);
}
private function removeListeners():void {
listButtons.removeEventListener(ItemClickEvent.ITEM_CLICK,clickHandler,false);
}
the 'removeListeners' function is called from the removedFromStage event on
the class, but that listener will still get added each time. it does not
help that profiler does not work on this machine, but what is the proper way
to remove all event listeners from a module so it can safely reload??
thanks,
d.