dd09029d814ae9d29b59f793820862119c8e33bf
[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%">
12         <mx:Button label="+" click="theMap.zoomIn();"/>
13         <mx:Button label="-" click="theMap.zoomOut();"/>
14       </mx:VBox>
15       <mx:Canvas id="map_area" clipContent="true"/>
16     </mx:HDividedBox>
17
18         <mx:Script><![CDATA[
19                 import net.systemeD.halcyon.*;
20                 import flash.system.Security;
21                 import flash.net.*;
22                 import flash.events.MouseEvent;
23                 import flash.display.Sprite;
24                 import mx.core.IChildList;
25         import mx.containers.Canvas;
26
27         public var theMap:Map;
28
29                 private function initApp():void {
30
31                         Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
32                         var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
33
34                         // map backdrop object
35             var b:Canvas = new Canvas();
36             b.height=200; b.width=200;
37             b.setStyle("backgroundColor", 0xFFFFEA);
38                         //var b:Sprite=new Sprite();
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                         // add debug field
75                         var t:TextField=new TextField();
76                         t.width=400; t.height=100; t.border=true; 
77                         t.multiline=true;
78                         _root.addChild(t);
79                         Globals.vars.debug=t;
80                 }
81
82         ]]></mx:Script>
83
84 </mx:Application>
85