Make the bug layer work with remote server - use POST, crossdomain.xml
authorAndy Allan <gravitystorm@gmail.com>
Mon, 22 Nov 2010 12:41:31 +0000 (12:41 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Mon, 22 Nov 2010 12:41:31 +0000 (12:41 +0000)
net/systemeD/potlatch2/BugLayer.as
net/systemeD/potlatch2/MarkerPanel.mxml
net/systemeD/potlatch2/utils/BugLoader.as

index 420d687..0de103c 100644 (file)
@@ -25,12 +25,15 @@ package net.systemeD.potlatch2 {
         public function closeBug(m:Marker):void {
             var id:String = m.getTag('bug_id');
             var status:String = BUG_STATUS_FIXED;
-            var comment:String = "no comment";
+            var comment:String = "NoComment";
             var nickname:String = "NoName";
 
-            //TODO make this a post request
+            //TODO urlencode stuff
+            var urlReq:URLRequest = new URLRequest(baseUrl+"changeBugStatus?id="+id+"&status="+status+"&comment="+comment+"&nickname="+nickname+"&key="+apiKey);
+            urlReq.method = "POST";
+            urlReq.data = '    '; // dear Adobe, this is nuts, kthxbye (you can't POST with an empty payload)
             var loader:URLLoader = new URLLoader();
-            loader.load(new URLRequest(baseUrl+"changeBugStatus?&id="+id+"&status="+status+"&comment="+comment+"&nickname="+nickname+"&key="+apiKey));
+            loader.load(urlReq);
             loader.addEventListener(Event.COMPLETE, bugClosed);
         }
 
index d9dd964..32985da 100644 (file)
@@ -6,7 +6,7 @@
 
 <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" height="100%">
   <mx:Text id="markerPanelText" text="You have selected a marker." width="100%" styleName="helpInfo" />
-  <mx:DataGrid editable="false" id="markerPanelDG" width="100%" height="100%">
+  <mx:DataGrid editable="false" id="markerPanelDG" width="100%" height="50%">
     <mx:columns>
       <mx:DataGridColumn editable="false" dataField="key" headerText="key" />
       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
index fcbc2a4..de24af6 100644 (file)
@@ -7,6 +7,7 @@ package net.systemeD.potlatch2.utils {
     import flash.net.*;
     import flash.events.*;
     import com.adobe.serialization.json.JSON;
+    import flash.system.Security;
 
     public class BugLoader {
 
@@ -20,14 +21,21 @@ package net.systemeD.potlatch2.utils {
             this.map = map;
             this.bugBaseURL = url;
             this.bugApiKey = bugApiKey;
+            var policyFile:String = bugBaseURL+"crossdomain.xml";
+            Security.loadPolicyFile(policyFile);
         }
 
         public function load():void {
             var loader:URLLoader = new URLLoader();
-            loader.load(new URLRequest(bugBaseURL+"getBugs.json?bbox="+map.edge_l+","+map.edge_b+","+map.edge_r+","+map.edge_t+"&key="+bugApiKey));
+            loader.load(new URLRequest(bugBaseURL+"getBugs?bbox="+map.edge_l+","+map.edge_b+","+map.edge_r+","+map.edge_t+"&key="+bugApiKey));
+            loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, balls);
             loader.addEventListener(Event.COMPLETE, parseJSON);
         }
 
+        public function balls(event:SecurityErrorEvent):void {
+            trace(event);
+        }
+
         private function parseJSON(event:Event):void {
             var result:String = String(event.target.data);
             var featureCollection:Object = JSON.decode(result);