thanks Carol. that's a smart choice to avoid using function closures
and it's inherent difficulties for removal. however, it not really that
much more of an elegant solution since it's a bit hacky, plus i'm a
little allergic to using MovieClips over Sprites, but it would be
certainly easier to manage and beggars can't be choosers!


here's hoping that Google supplies a better solution to handle custom
data in future updates of the API


since my post i've learned (the very ugly way) how to remove event
listeners added via function closures. here's my code (custom data is
supplied from an XML file):



private function mapReadyEventHandler(evt:MapEvent):void
{
//Remove Event Listener
evt.currentTarget.removeEventListener(MapEvent.MAP_READY,
mapReadyEventHandler);

// // // MAP STYLE CODE // // //

//Assign Marker For Each XML Station Element
for each (var station:XML in XMLData..station)
{
//Assign Marker Options
var markerOptions:MarkerOptions = new MarkerOptions();
markerOptions.icon = new StationMarkerIcon();
markerOptions.hasShadow = false;

//Add Created Marker To Map Overlay
map.addOverlay(createMarker(station.lat, station.long, markerOptions,
station.name, station.cars));
}
}


//Create Marker
private function createMarker(latitude:Number, longitude:Number,
markerOptions:MarkerOptions, stationName:String,
availableCars:uint):Marker
{
var functionClosure:Function;
var resultMarker:Marker = new Marker(new LatLng(latitude, longitude),
markerOptions);

//Assign Mouse Event Listener To Marker
resultMarker.addEventListener(MapMouseEvent.CLICK,
function(evt:MapMouseEvent):void
{
//Reference Function For Event Listener Removal:
removeEventListener(MapMouseEvent.CLICK, functionClosure)
functionClosure = arguments.callee;

//Event
trace(latitude, longitude, stationName, availableCars)
});

return resultMarker;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api-for-flash?hl=en.

Reply via email to