remove mx.controls.Alert dependency from halcyon_viewer - Flex should only be used...
authorRichard Fairhurst <richard@systemed.net>
Wed, 1 Sep 2010 12:27:17 +0000 (12:27 +0000)
committerRichard Fairhurst <richard@systemed.net>
Wed, 1 Sep 2010 12:27:17 +0000 (12:27 +0000)
net/systemeD/halcyon/MapEvent.as
net/systemeD/halcyon/connection/XMLConnection.as
potlatch2.mxml

index 078554a..b0f090f 100644 (file)
@@ -8,6 +8,7 @@ package net.systemeD.halcyon {
                public static const RESIZE:String = "resize";
                public static const MOVE:String = "move";
                public static const NUDGE_BACKGROUND:String = "nudge_background";
+               public static const ERROR:String = "error";
 
                public var params:Object;
 
index 6bc0dad..f003cfe 100644 (file)
@@ -5,9 +5,8 @@ package net.systemeD.halcyon.connection {
        import flash.system.Security;
        import flash.net.*;
     import org.iotashan.oauth.*;
-       import mx.controls.Alert;
 
-       import net.systemeD.halcyon.Globals;
+       import net.systemeD.halcyon.MapEvent;
 
        public class XMLConnection extends XMLBaseConnection {
 
@@ -40,7 +39,7 @@ package net.systemeD.halcyon.connection {
                }
 
         private function errorOnMapLoad(event:Event):void {
-                       Alert.show("Couldn't load the map", 'Error', mx.controls.Alert.OK);
+                       dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "Couldn't load the map" } ));
         }
         private function mapLoadStatus(event:HTTPStatusEvent):void {
             trace("loading map status = "+event.status);
@@ -181,7 +180,7 @@ package net.systemeD.halcyon.connection {
         }
 
         private function diffUploadError(event:IOErrorEvent):void {
-                       Alert.show("Couldn't upload data: "+httpStatus+" "+event.text, 'Error', mx.controls.Alert.OK);
+                       dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "Couldn't upload data: "+httpStatus+" "+event.text } ));
                dispatchEvent(new SaveCompleteEvent(SAVE_COMPLETED, false));
         }
 
index 4f6bca5..b340a7e 100755 (executable)
@@ -83,6 +83,7 @@
         import mx.events.DragEvent;
         import mx.managers.DragManager;
         import mx.core.DragSource;
+        import mx.controls.Alert;
 
         public var theMap:Map;
         public var theController:EditController;
             conn.addEventListener(Connection.SAVE_COMPLETED, onDataComplete);
             conn.addEventListener(Connection.DATA_DIRTY, onDataDirty);
             conn.addEventListener(Connection.DATA_CLEAN, onDataClean);
+                       conn.addEventListener(MapEvent.ERROR, onMapError);
 
                        // create GPS trackloader
                        trackLoader=new TrackLoader(theMap,conn.apiBase);
                }
                
+               public function onMapError(event:MapEvent):void {
+                       Alert.show(event.params.message, 'Error', mx.controls.Alert.OK);
+               }
+
         public function onResizeMap():void {
             if ( theMap != null )
                 theMap.updateSize(map_area.width, map_area.height);