Download on resize
[potlatch2.git] / net / systemeD / halcyon / Map.as
index 3902f36..29aded4 100644 (file)
@@ -64,6 +64,7 @@ package net.systemeD.halcyon {
                public const NOT_DRAGGING:uint=0;                               //  |
                public const NOT_MOVED:uint=1;                                  //  |
                public const DRAGGING:uint=2;                                   //  |
+               public const SWALLOW_MOUSEUP:uint=3;                    //  |
                /** How far the map can be dragged without actually triggering a pan. */
                public const TOLERANCE:uint=7;                                  //  |
                
@@ -205,6 +206,7 @@ package net.systemeD.halcyon {
                        mapwidth = w; centre_lon=coord2lon(-getX()+w/2);
                        mapheight= h; centre_lat=coord2lat(-getY()+h/2);
                        setScrollRectSize(w,h);
+                       updateCoords(getX(),getY());
 
                        this.dispatchEvent(new MapEvent(MapEvent.RESIZE, {width:w, height:h}));
                        
@@ -389,7 +391,8 @@ package net.systemeD.halcyon {
                /** Prepare for being dragged by recording start time and location of mouse. */
                public function mouseDownHandler(event:MouseEvent):void {
                        if (!_draggable) { return; }
-                       dragstate=NOT_MOVED;
+                       if (dragstate==DRAGGING) { moveMap(x,y); dragstate=SWALLOW_MOUSEUP; }   // cancel drag if mouse-up occurred outside the window (thanks, Safari)
+                       else { dragstate=NOT_MOVED; }
                        lastxmouse=stage.mouseX; downX=stage.mouseX;
                        lastymouse=stage.mouseY; downY=stage.mouseY;
                        downTime=new Date().getTime();
@@ -428,6 +431,7 @@ package net.systemeD.halcyon {
 
                private function everyFrame(event:Event):void {
                        if (tileset) { tileset.serviceQueue(); }
+                       if (stage.focus && !stage.contains(stage.focus)) { stage.focus=stage; }
                }
 
                // ------------------------------------------------------------------------------------------
@@ -446,21 +450,5 @@ package net.systemeD.halcyon {
                        }
                }
 
-               // ------------------------------------------------------------------------------------------
-               // Debugging
-               
-               public function clearDebug():void {
-                       if (!Globals.vars.hasOwnProperty('debug')) return;
-                       Globals.vars.debug.text='';
-               }
-                       
-               public function addDebug(text:String):void {
-                       trace(text);
-                       if (!Globals.vars.hasOwnProperty('debug')) return;
-                       if (!Globals.vars.debug.visible) return;
-                       Globals.vars.debug.appendText(text+"\n");
-                       Globals.vars.debug.scrollV=Globals.vars.debug.maxScrollV;
-               }
-
        }
 }