da1818bfd42a539527481802dda324409cbe229a
[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 bustin.dev.Inspector;
12
13         public class halcyon_viewer extends Sprite {
14
15                 public var theMap:Map;
16
17                 function halcyon_viewer():void {
18                         stage.align = StageAlign.TOP_LEFT;
19                         stage.scaleMode = StageScaleMode.NO_SCALE;
20                         this.loaderInfo.addEventListener(Event.COMPLETE, init);
21                 }
22         
23                 private function init(e:Event):void {
24
25                         // add debug field
26                         var t:TextField=new TextField();
27                         t.width=400; t.height=100; t.x=400; t.border=true;
28                         t.multiline=true;
29                         addChild(t);
30                         Globals.vars.debug=t;
31                         t.visible = true;
32
33                         theMap = new Map(this.loaderInfo.parameters);
34             theMap.updateSize(stage.stageWidth, stage.stageHeight);
35                         addChild(theMap);
36                         Globals.vars.root=theMap;
37
38                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
39                         stage.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
40                         stage.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
41 //                      Inspector.getInstance().init(stage);
42
43                         var z1:Sprite=new Sprite();
44                         z1.graphics.beginFill(0x0000FF); z1.graphics.drawRoundRect(0,0,20,20,5); z1.graphics.endFill();
45                         z1.graphics.lineStyle(2,0xFFFFFF);
46                         z1.graphics.moveTo(5,10); z1.graphics.lineTo(15,10);
47                         z1.graphics.moveTo(10,5); z1.graphics.lineTo(10,15);
48                         z1.x=5; z1.y=5; z1.buttonMode=true;
49                         z1.addEventListener(MouseEvent.CLICK, zoomInHandler, false, 1);
50                         addChild(z1);
51
52                         var z2:Sprite=new Sprite();
53                         z2.graphics.beginFill(0x0000FF); z2.graphics.drawRoundRect(0,0,20,20,5); z2.graphics.endFill();
54                         z2.graphics.lineStyle(2,0xFFFFFF);
55                         z2.graphics.moveTo(5,10); z2.graphics.lineTo(15,10);
56                         z2.x=5; z2.y=30; z2.buttonMode=true;
57                         z2.addEventListener(MouseEvent.CLICK, zoomOutHandler, false, 1);
58                         addChild(z2);
59
60                         if (this.loaderInfo.parameters.hasOwnProperty('responder')) {
61                 var controller:JSController = new JSController(theMap, loaderInfo.parameters['responder']);
62                                 controller.setActive();
63                         }
64                 }
65                 
66                 private function zoomInHandler(e:MouseEvent):void  { e.stopPropagation(); theMap.zoomIn(); }
67                 private function zoomOutHandler(e:MouseEvent):void { e.stopPropagation(); theMap.zoomOut(); }
68         }
69 }