GpxAS3 icon indicating copy to clipboard operation
GpxAS3 copied to clipboard

GPXService.load is synchronous

Open vitch opened this issue 14 years ago • 2 comments

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

vitch avatar Sep 23 '10 18:09 vitch

(my test gpx file is largish at 897kb with around 5000 trkpt nodes so it takes 10 seconds to parse!)

vitch avatar Sep 23 '10 18:09 vitch

Hmmmm, let me take a look at this and see what's up. Thanks for posting the issue!

ryanstewart avatar Sep 25 '10 06:09 ryanstewart