Merge branch 'master' into mapquest
[potlatch2.git] / potlatch2.mxml
index 64124dca1769970e9892729c6b15c35a6cd1ca7b..72153cc000fba3eb44a324b3279f3229cabd6e4f 100644 (file)
@@ -9,7 +9,9 @@
        horizontalAlign="center" 
        addedToStage="initApp()"
        preloader="net.systemeD.potlatch2.Preloader">
-       
+
+    <map:LocalizationMap xmlns:map="l10n.map.*" />
+
        <mx:Style source="styles/Application.css"/>
 
     <mx:Glow id="glowImage" duration="100" 
@@ -38,9 +40,9 @@
                                                     theMap.removeVectorLayer(theMap.findVectorLayer('GPS tracks')); }">
                        <mx:dataProvider>
                                <mx:Array>
-                                       <mx:Object label="GPS data" />
-                                       <mx:Object label="My tracks" />
-                                       <mx:Object label="Clear" />
+                                       <mx:Object label="GPS data" id="gpsData" />
+                                       <mx:Object label="My tracks" id="myTracks" />
+                                       <mx:Object label="Clear" id="clearGps" />
                                </mx:Array>
                        </mx:dataProvider>
                </mx:PopUpMenuButton>
         <mx:Button id="redo" label="Redo" click="MainUndoStack.getGlobalStack().redo();" styleName="appBarButton"
             enabled="{MainUndoStack.getGlobalStack().canRedo()}"/>
         <mx:Spacer width="100%"/>
-        <mx:Button label="Help" click="new HelpDialog().init();" styleName="appBarButton" />
-        <mx:Button label="Options" click="new OptionsDialog().init();" styleName="appBarButton" /> 
+        <mx:Button id="helpButton" label="Help" click="new HelpDialog().init();" styleName="appBarButton" />
+        <mx:Button id="optionsButton" label="Options" click="new OptionsDialog().init();" styleName="appBarButton" />
         <mx:Button label="Save" icon="@Embed('embedded/upload.svg')" disabledIcon="@Embed('embedded/upload_disabled.svg')" styleName="appBarButton"
                        click="SaveManager.saveChanges();" id="saveButton" enabled="false"/>
     </mx:ApplicationControlBar>
-
-    <map:LocalizationMap xmlns:map="l10n.map.*" />
     
     <mx:HDividedBox width="100%" height="100%">
 
 
                private function initApp():void {
 
-            /* For reasons that I don't yet understand, the en_US locale is the default and doesn't work at all. Use en_GB instead. */
-            /* Change this to another locale (e.g. fr_FR) to see the differences. This will obviously become done differently at some point. */
-            dispatchEvent(new LocaleEvent(LocaleEvent.LOAD_LOCALE,'en_GB'));
+            /* For reasons that I don't yet understand, the en_US locale is the default and doesn't work at all. */
+            /* Change this to another locale (e.g. fr_FR) to see the differences. */
+            if (loaderInfo.parameters['locale']) {
+              dispatchEvent(new LocaleEvent(LocaleEvent.LOAD_LOCALE,loaderInfo.parameters['locale']));
+            }
 
                        Globals.vars.map_area = map_area;
                        Globals.vars.root = map_area.rawChildren;                       // set up global reference to root level
 
                        // Get the tags
             var tags:Array = event.dragSource.dataForFormat('tags') as Array;
-            var mapLoc:Point = Globals.vars.root.globalToLocal(new Point(event.stageX, event.stageY));
+
+            // If you dnd quick enough, this exposes a flex bug and event.stageX/Y become negative.
+            // Take the mouse positions from a displayObject's stage for consistent results.
+            var mapLoc:Point = Globals.vars.root.globalToLocal(new Point(event.target.stage.mouseX, event.target.stage.mouseY));
             var lat:Number = Globals.vars.root.coord2lat(mapLoc.y);
             var lon:Number = Globals.vars.root.coord2lon(mapLoc.x);