Commenting for ASDoc
[potlatch2.git] / halcyon_viewer.as
1 package {
2
3         import net.systemeD.halcyon.*;
4         import net.systemeD.halcyon.connection.*;
5         import flash.system.Security;
6         import flash.net.*;
7         import flash.events.*;
8         import flash.events.MouseEvent;
9         import flash.display.*;
10         import flash.text.TextField;
11         import flash.external.*;
12 //      import bustin.dev.Inspector;
13
14         public class halcyon_viewer extends Sprite {
15
16                 public var theMap:Map;
17
18                 function halcyon_viewer():void {
19                         stage.align = StageAlign.TOP_LEFT;
20                         stage.scaleMode = StageScaleMode.NO_SCALE;
21                         this.loaderInfo.addEventListener(Event.COMPLETE, init);
22                 }
23         
24                 private function init(e:Event):void {
25
26                         theMap = new Map(this.loaderInfo.parameters);
27             theMap.updateSize(stage.stageWidth, stage.stageHeight);
28                         addChild(theMap);
29                         Globals.vars.root=theMap;
30                         Globals.vars.nocache = loaderInfo.parameters['nocache'] == 'true';
31
32                         // add debug field
33                         var t:TextField=new TextField();
34                         t.width=400; t.height=100; t.x=400; t.border=true;
35                         t.multiline=true;
36                         addChild(t);
37                         Globals.vars.debug=t;
38             t.visible = loaderInfo.parameters["show_debug"] == 'true';
39
40                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
41                         stage.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
42                         stage.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
43 //                      Inspector.getInstance().init(stage);
44
45                         var z1:Sprite=new Sprite();
46                         z1.graphics.beginFill(0x0000FF); z1.graphics.drawRoundRect(0,0,20,20,5); z1.graphics.endFill();
47                         z1.graphics.lineStyle(2,0xFFFFFF);
48                         z1.graphics.moveTo(5,10); z1.graphics.lineTo(15,10);
49                         z1.graphics.moveTo(10,5); z1.graphics.lineTo(10,15);
50                         z1.x=5; z1.y=5; z1.buttonMode=true;
51                         z1.addEventListener(MouseEvent.CLICK, zoomInHandler, false, 1);
52                         addChild(z1);
53
54                         var z2:Sprite=new Sprite();
55                         z2.graphics.beginFill(0x0000FF); z2.graphics.drawRoundRect(0,0,20,20,5); z2.graphics.endFill();
56                         z2.graphics.lineStyle(2,0xFFFFFF);
57                         z2.graphics.moveTo(5,10); z2.graphics.lineTo(15,10);
58                         z2.x=5; z2.y=30; z2.buttonMode=true;
59                         z2.addEventListener(MouseEvent.CLICK, zoomOutHandler, false, 1);
60                         addChild(z2);
61
62                         if (this.loaderInfo.parameters.hasOwnProperty('responder')) {
63                 var controller:JSController = new JSController(theMap, loaderInfo.parameters['responder']);
64                                 controller.setActive();
65                         }
66
67                         ExternalInterface.addCallback('refreshCSS', onRefreshCSS);
68                         ExternalInterface.addCallback('jumpTo', onJumpTo);
69                 }
70
71                 private function onRefreshCSS(str:String):void {
72                         theMap.setStyle(str);
73                 }               
74                 private function onJumpTo(lat:Number,lon:Number):void {
75                         theMap.init(lat,lon);
76                 }
77
78                 private function zoomInHandler(e:MouseEvent):void  { e.stopPropagation(); theMap.zoomIn(); }
79                 private function zoomOutHandler(e:MouseEvent):void { e.stopPropagation(); theMap.zoomOut(); }
80
81
82         }
83 }