GpxAS3
GpxAS3 copied to clipboard
GPXService.load is synchronous
The comment in the example gives the impression that the point of the GPXService
is to allow you to parse a file asynchronously. However, it seems that the GPXService
is pointless as the call to load will block the flash player and the ParseEvent.PARSE_COMPLETE
will fire before the following line of code is reached. e.g.
private function onXmlLoaded(event:Event):void
{
var gpxSrv:GPXService = new GPXService();
gpxSrv.addEventListener(ParseEvent.PARSE_COMPLETE, onGpxParse);
var loadedData:String = xmlLoader.data;
gpxSrv.load(new XML(loadedData));
trace('NEXT LINE', getTimer());
}
private function onGpxParse(event:ParseEvent):void
{
var gpx:GPX = event.gpx;
trace('DONE', getTimer());
trace(gpx);
}
Will trace:
DONE 10613
[object GPX]
NEXT LINE 10613
(my test gpx file is largish at 897kb with around 5000 trkpt nodes so it takes 10 seconds to parse!)
Hmmmm, let me take a look at this and see what's up. Thanks for posting the issue!