Move security file handling down into the connection for buglayers
authorAndy Allan <andy@gravitystorm.co.uk>
Mon, 23 May 2011 17:45:11 +0000 (18:45 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Mon, 23 May 2011 17:45:11 +0000 (18:45 +0100)
net/systemeD/potlatch2/BugConnection.as
net/systemeD/potlatch2/utils/BugLoader.as

index 006e5b9..9e36906 100644 (file)
@@ -6,6 +6,7 @@ package net.systemeD.potlatch2 {
     import net.systemeD.halcyon.connection.actions.*;
     import flash.net.*;
     import flash.events.*;
+    import flash.system.Security;
     import com.adobe.serialization.json.JSON;
 
     /** A VectorLayer that can be used to load and display bugs from MapDust-compatible APIs.
@@ -35,7 +36,7 @@ package net.systemeD.potlatch2 {
             this.baseUrl = baseUrl;
             this.apiKey = apiKey;
             this.detailsUrl = detailsURL;
-            super(n, baseUrl, null, null);
+            super(n, baseUrl, baseUrl+"crossdomain.xml", null);
         }
 
         public function closeBug(m:Marker, nickname:String, comment:String, status:String = null):void {
@@ -66,11 +67,15 @@ package net.systemeD.potlatch2 {
 
         public override function loadBbox(left:Number, right:Number,
                                 top:Number, bottom:Number):void {
+
+            // Should be guarded against multiple calls really.
+            if (policyURL != "") { Security.loadPolicyFile(policyURL); trace("policy");};
+
             var loader:URLLoader = new URLLoader();
-            loader.load(new URLRequest(baseUrl+"getBugs?bbox="+left+","+bottom+","+right+","+top+"&key="+apiKey+"&filter_status="+filter_status+"&filter_type="+filter_type+commentType));
             loader.addEventListener(Event.COMPLETE, parseJSON);
             loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleError);
             loader.addEventListener(IOErrorEvent.IO_ERROR, handleError);
+            loader.load(new URLRequest(baseUrl+"getBugs?bbox="+left+","+bottom+","+right+","+top+"&key="+apiKey+"&filter_status="+filter_status+"&filter_type="+filter_type+commentType));
         }
 
                private function handleError(event:Event):void {
index b9532cb..7cb6bf4 100644 (file)
@@ -30,18 +30,10 @@ package net.systemeD.potlatch2.utils {
         }
 
         public function load():void {
-            connection.loadBbox(map.edge_l, map.edge_r, map.edge_t, map.edge_b);
-        }
-
-        private function get layer():MapPaint {
             if (!_layer) {
-                // should be done by the connection
-                var policyFile:String = bugBaseURL+"crossdomain.xml";
-                Security.loadPolicyFile(policyFile);
-
                 _layer = map.addLayer(connection, STYLESHEET);
             }
-            return _layer;
+            connection.loadBbox(map.edge_l, map.edge_r, map.edge_t, map.edge_b);
         }
     }
 }
\ No newline at end of file