split potlatch2 into entirely different namespace
[potlatch2.git] / halcyon.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application 
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         xmlns:halcyon="net.systemeD.halcyon.*"
5         xmlns:potlatch2="net.systemeD.potlatch2.*"
6         layout="vertical"
7         horizontalAlign="center" 
8         addedToStage="initApp()">
9
10     <mx:HDividedBox width="100%" height="100%">
11
12       <mx:VBox height="100%" width="25%" horizontalAlign="right">
13         <mx:HBox>
14           <mx:Button label="-" click="theMap.zoomOut();"/>
15           <mx:Button label="+" click="theMap.zoomIn();"/>
16         </mx:HBox>
17         <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
18       </mx:VBox>
19       <mx:Canvas id="map_area" width="75%" height="100%" resize="onResizeMap()"/>
20     </mx:HDividedBox>
21
22         <mx:Script><![CDATA[
23                 import net.systemeD.halcyon.*;
24                 import net.systemeD.potlatch2.*;
25                 import flash.system.Security;
26                 import flash.net.*;
27                 import flash.events.MouseEvent;
28                 import flash.display.Sprite;
29                 import mx.core.IChildList;
30         import mx.containers.Canvas;
31                 import mx.core.Application;
32
33         public var theMap:Map;
34
35                 private function initApp():void {
36
37                         Globals.vars.map_area=map_area;
38                         Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
39                         var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
40
41                         // map backdrop object
42             var w:uint = map_area.width;
43             var h:uint = map_area.height;
44             var b:Sprite = new Sprite();
45             b.height=h; b.width=w;
46             b.graphics.beginFill(0xFFFFEA,100); 
47             b.graphics.drawRect(0,0,w,h); 
48             b.graphics.endFill();
49                         _root.addChild(b);
50
51                         // add map
52                         theMap=new Map(this.loaderInfo.parameters);
53                         theMap.backdrop=b;
54                         _root.addChild(theMap);
55             theMap.updateSize(w, h);
56
57                         // add mask for map
58                         var s:Sprite=new Sprite();
59                         s.graphics.beginFill(0xFFFFFF,100);
60                         s.graphics.drawRect(0,0,w,h);
61                         s.graphics.endFill();
62                         _root.addChild(s);
63                         theMap.mask=s;
64
65                         // add crosshair
66                         /*s=new Sprite();
67                         s.graphics.lineStyle(2,0);
68                         s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
69                         s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
70                         s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
71                         s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
72                         _root.addChild(s);*/
73
74                         // mouse-up handler attached to stage, so the user can release outside the map
75                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
76                         theMap.backdrop.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
77                         theMap.backdrop.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
78
79                         // keyboard event attached to stage
80                         stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
81
82                         // example listener event
83                         var myListenerObj:Object = new Object();
84                         myListenerObj.mapHandler=function(event:MapEvent):void {
85                                 Globals.vars.debug.appendText("Download event fired - "+event.minlat+","+event.minlon+"\n");
86                         };
87                         theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
88
89                         // add debug field
90                         var t:TextField=new TextField();
91                         t.width=400; t.height=100; t.border=true;
92                         t.multiline=true;
93                         _root.addChild(t);
94                         Globals.vars.debug=t;
95             t.visible = true;
96
97             var controller:EditController = new EditController(theMap, tagViewer);
98             controller.setActive();
99                 }
100
101         public function onResizeMap():void {
102             if ( theMap != null )
103                 theMap.updateSize(map_area.width, map_area.height);
104         }
105
106         ]]></mx:Script>
107
108 </mx:Application>
109