I have a simple Google Maps application in Flash and ActionScript 3
which does some simple mapping actions (marker and panning) and also
looks up a lat/lng using a URL load of the Google geocode API
(maps.google.com/maps/geo?q=) to get the marker location.

It all works great in the Adobe Flash CS4 Pro development app on my
laptop.

But when I put the published swf onto a web server and embed it in
HTML, it the geocode lookup grinds processing to a halt.  If I comment
out the geocode call and hard-code a lat/lng value instead of the
event handler, then it runs fine in the browser (IE, Firefox 3.0.4,
and Chrome).  I had set the publishing options to enable network
access, and that clearly works because the map is displayed, panned,
and marker set as commanded by my ActionScript code.

When the geocode call is present in the swf, the status text displayed
at the bottom of Firefox is "Read map.google.com" when it freezes up.
The map stays displayed and can still be zoomed, dragged, etc. using
the mouse but the ActionScript obviously doesn't execute.

The same ActionScript when run from the Adobe CS4 development program
has no problem calling the geocode API over and over, quickly.  But
from a browser even trying to do it once stops the swf code execution
in its tracks.  I also tried a different geocoding API (geonames.org)
and the exact same symptom happens - works fine from CS4, hangs in
browser, so it doesn't seem the Google API is at fault.

Here's the part of the code that causes the problem.  The HTML page
for embedding the swf is done as similar as possible to the HTML
example in the last page of the tutorial here, except I specify the
key in the AS3 code instead of in the html (same key for the map and
geocode): 
http://code.google.com/apis/maps/documentation/flash/tutorial-flash.html

Any help or suggestions much appreciated.  Basically my application
needs to look up some lat/lng points dymanically and mark them.
Hopefully that's something feasible in a client-side mashup.

...
   var geoCodeURL = "http://maps.google.com/maps/geo?q="; +
                    locStringWithPlusses +
                    "&output=csv" + "&key=" + googleKey;

   var request:URLRequest = new URLRequest(geoCodeURL);
   var loader:URLLoader = new URLLoader();
   loader.dataFormat = URLLoaderDataFormat.TEXT;
   loader.addEventListener(Event.COMPLETE, handleGeoCode);
   loader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
   loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR ,
handleSecurityError);
   loader.load(request);
...

function handleGeoCode(evt:Event):void {
    var response:String = evt.target.data as String;
    trace("   data received from geo URL: " + response);
    var results:Array = response.split(/,/);
    var lat = results[2];
    var lng = results[3];
    var spot:LatLng = new LatLng(lat, lng);
    var marker:Marker = new Marker(spot);
    map.addOverlay(marker);
    map.panTo(spot);
}
--~--~---------~--~----~------------~-------~--~----~
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