initial work on tag editor
[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         layout="vertical"
6         horizontalAlign="center" 
7         addedToStage="initApp()">
8
9     <mx:HDividedBox width="100%" height="100%">
10
11       <mx:VBox height="100%" width="25%">
12         <mx:Button label="+" click="theMap.zoomIn();"/>
13         <mx:Button label="-" click="theMap.zoomOut();"/>
14         <halcyon:TagViewer width="100%" height="100%" id="tagViewer"/>
15       </mx:VBox>
16       <mx:Canvas id="map_area" width="75%"/>
17     </mx:HDividedBox>
18
19         <mx:Script><![CDATA[
20                 import net.systemeD.halcyon.*;
21                 import flash.system.Security;
22                 import flash.net.*;
23                 import flash.events.MouseEvent;
24                 import flash.display.Sprite;
25                 import mx.core.IChildList;
26         import mx.containers.Canvas;
27                 import mx.core.Application;
28
29         public var theMap:Map;
30
31                 private function initApp():void {
32
33                         Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
34                         var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
35
36                         // map backdrop object
37             var b:Sprite = new Sprite();
38             b.height=200; b.width=200;
39             b.graphics.beginFill(0xFFFFEA,100); 
40             b.graphics.drawRect(0,0,200,200); 
41             b.graphics.endFill();
42                         _root.addChild(b);
43
44                         // add map
45                         theMap=new Map();
46                         theMap.backdrop=b;
47                         _root.addChild(theMap);
48
49                         // add mask for map
50                         var s:Sprite=new Sprite();
51                         s.graphics.beginFill(0xFFFFFF,100);
52                         s.graphics.drawRect(0,0,200,200);
53                         s.graphics.endFill();
54                         _root.addChild(s);
55                         theMap.mask=s;
56
57                         // add crosshair
58                         s=new Sprite();
59                         s.graphics.lineStyle(2,0);
60                         s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
61                         s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
62                         s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
63                         s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
64                         _root.addChild(s);
65
66                         // mouse-up handler attached to stage, so the user can release outside the map
67                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
68                         theMap.backdrop.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
69                         theMap.backdrop.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
70
71                         // keyboard event attached to stage
72                         stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
73
74                         // example listener event
75                         var myListenerObj:Object = new Object();
76                         myListenerObj.mapHandler=function(event:MapEvent):void {
77                                 Globals.vars.debug.appendText("Download event fired - "+event.minlat+","+event.minlon+"\n");
78                         };
79                         theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
80
81                         // add debug field
82                         var t:TextField=new TextField();
83                         t.width=400; t.height=100; t.border=true; 
84                         t.multiline=true;
85                         _root.addChild(t);
86                         Globals.vars.debug=t;
87
88             var controller:EditController = new EditController(theMap, tagViewer);
89             controller.setActive();
90                 }
91
92         ]]></mx:Script>
93
94 </mx:Application>
95