removeEventListener for MapMouseEvent not working

655
2
04-19-2011 06:15 AM
KathleenBrenkert
Occasional Contributor
I am trying to remove an event listener with no luck.  In short the event listener is added if my address to location provides no results.  The listener picks up a map click and then reverse geocodes.  This part works perfectly, however I want to next remove this listener and add a new one so that the next map click calls a different function and doesn't perform another reverse geocode.  Any ideas? Nothing I've come up with works and I've placed the .removeEventListener code below in several different locations in my code.

private function myMapClick(event:MapMouseEvent):void
   {
    reverseLocate.locationToAddress(event.mapPoint, 100);
    myMap.removeEventListener(MapMouseEvent.MAP_CLICK,doNothing);
   }
Tags (2)
0 Kudos
2 Replies
IvanBespalov
Occasional Contributor III
Read Adobe reference

/**
 * Listen map click
 */
private function myMapClick(event:MapMouseEvent):void
{
     trace(">>> myMapClick() executed");
     // remove listener
     myMap.removeEventListener(MapMouseEvent.MAP_CLICK, myMapClick);
     // add listener
     myMap.addEventListener(MapMouseEvent.MAP_CLICK, myMapClick1);
}

/**
 * Listen map click
 */
private function myMapClick1(event:MapMouseEvent):void
{
     trace(">>> myMapClick1() executed");
     // remove listener
     myMap.removeEventListener(MapMouseEvent.MAP_CLICK, myMapClick1);
     // add listener
     myMap.addEventListener(MapMouseEvent.MAP_CLICK, myMapClick);
}
0 Kudos
KathleenBrenkert
Occasional Contributor
thank you!
0 Kudos