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