remove the dnd attribute from tower - oops, I didn't spot that - and it would be...
[potlatch2.git] / halcyon_viewer.as
old mode 100755 (executable)
new mode 100644 (file)
index 74f0aa1..3b01b9e
@@ -8,7 +8,8 @@ package {
        import flash.events.MouseEvent;
        import flash.display.*;
        import flash.text.TextField;
-       import bustin.dev.Inspector;
+       import flash.external.*;
+//     import bustin.dev.Inspector;
 
        public class halcyon_viewer extends Sprite {
 
@@ -22,23 +23,24 @@ package {
        
                private function init(e:Event):void {
 
+                       theMap = new Map(this.loaderInfo.parameters);
+            theMap.updateSize(stage.stageWidth, stage.stageHeight);
+                       addChild(theMap);
+                       Globals.vars.root=theMap;
+                       Globals.vars.nocache = loaderInfo.parameters['nocache'] == 'true';
+
                        // add debug field
                        var t:TextField=new TextField();
                        t.width=400; t.height=100; t.x=400; t.border=true;
                        t.multiline=true;
                        addChild(t);
                        Globals.vars.debug=t;
-                       t.visible = true;
-
-                       theMap = new Map(this.loaderInfo.parameters);
-            theMap.updateSize(stage.stageWidth, stage.stageHeight);
-                       addChild(theMap);
-                       Globals.vars.root=theMap;
+            t.visible = loaderInfo.parameters["show_debug"] == 'true';
 
-//                     stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
-//                     stage.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
-//                     stage.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
-                       Inspector.getInstance().init(stage);
+                       stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
+                       stage.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
+                       stage.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
+//                     Inspector.getInstance().init(stage);
 
                        var z1:Sprite=new Sprite();
                        z1.graphics.beginFill(0x0000FF); z1.graphics.drawRoundRect(0,0,20,20,5); z1.graphics.endFill();
@@ -61,9 +63,21 @@ package {
                var controller:JSController = new JSController(theMap, loaderInfo.parameters['responder']);
                                controller.setActive();
                        }
+
+                       ExternalInterface.addCallback('refreshCSS', onRefreshCSS);
+                       ExternalInterface.addCallback('jumpTo', onJumpTo);
+               }
+
+               private function onRefreshCSS(str:String):void {
+                       theMap.setStyle(str);
+               }               
+               private function onJumpTo(lat:Number,lon:Number):void {
+                       theMap.init(lat,lon);
                }
-               
+
                private function zoomInHandler(e:MouseEvent):void  { e.stopPropagation(); theMap.zoomIn(); }
                private function zoomOutHandler(e:MouseEvent):void { e.stopPropagation(); theMap.zoomOut(); }
+
+
        }
 }