Store the returned traces in the connection, and provide accessor methods for retrieval.
authorAndy Allan <gravitystorm@gmail.com>
Mon, 11 Oct 2010 17:04:06 +0000 (17:04 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Mon, 11 Oct 2010 17:04:06 +0000 (17:04 +0000)
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as

index d856b8a..7c9b1a8 100755 (executable)
@@ -82,6 +82,7 @@ package net.systemeD.halcyon.connection {
                public static var REMOVED_FROM_RELATION:String = "removed_from_relation";
                public static var SUSPEND_REDRAW:String = "suspend_redraw";
                public static var RESUME_REDRAW:String = "resume_redraw";
+        public static var TRACES_LOADED:String = "traces_loaded";
 
         // store the data we download
         private var negativeID:Number = -1;
@@ -338,7 +339,14 @@ package net.systemeD.halcyon.connection {
                        }
             return changeset;
         }
-        
+
+        protected function addTrace(t:Object):void {
+            traces.push(t);
+        }
+
+        public function getTraces():Array {
+            return traces;
+        }
 
         // these are functions that the Connection implementation is expected to
         // provide. This class has some generic helpers for the implementation.
index e5eaa24..da8cad6 100644 (file)
@@ -326,8 +326,16 @@ package net.systemeD.halcyon.connection {
             //  create a trace object
             //  store in connection.traces
             //emit event
-                        var traces:XML = new XML(URLLoader(event.target).data);
-            trace(traces);
+            var files:XML = new XML(URLLoader(event.target).data);
+            for each(var traceData:XML in files.gpx_file) {
+              var t:Object = {};
+              t.id = traceData.@id;
+              t.name = traceData.@name;
+              t.url = Connection.apiBaseURL+"gpx/"+t.id+"/data";
+              addTrace(t);
+            }
+            trace("loaded gpx files");
+            dispatchEvent(new Event(TRACES_LOADED));
         }
        }
 }