1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:halcyon="net.systemeD.halcyon.*"
5 xmlns:potlatch2="net.systemeD.potlatch2.*"
7 horizontalAlign="center"
8 addedToStage="initApp()">
10 <mx:Style source="styles/Application.css"/>
12 <mx:Glow id="glowImage" duration="100"
13 alphaFrom="0.3" alphaTo="1.0"
14 blurXFrom="0.0" blurXTo="5.0"
15 blurYFrom="0.0" blurYTo="5.0"
17 <mx:Glow id="unglowImage" duration="100"
18 alphaFrom="1.0" alphaTo="0.3"
19 blurXFrom="5.0" blurXTo="0.0"
20 blurYFrom="5.0" blurYTo="0.0"
22 <mx:WipeLeft id="wipeOut" duration="250"/>
23 <mx:WipeRight id="wipeIn" duration="250"/>
25 <mx:ApplicationControlBar dock="true">
26 <mx:Spacer width="100%"/>
27 <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"/>
28 </mx:ApplicationControlBar>
30 <mx:HDividedBox width="100%" height="100%">
32 <mx:VBox height="100%" width="25%" horizontalAlign="right">
33 <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
35 <mx:Canvas width="75%" height="100%">
36 <mx:Canvas id="map_area" resize="onResizeMap()"
37 top="0" left="0" width="100%" height="100%">
39 <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
40 rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
41 <mx:Image source="@Embed('embedded/zoomOut.svg')" right="3" top="20" click="theMap.zoomOut();"
42 rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
43 <mx:Label id="dataWorking" text="" right="20" top="3"
44 showEffect="{wipeIn}" hideEffect="{wipeOut}"/>
49 import net.systemeD.halcyon.*;
50 import net.systemeD.halcyon.connection.*;
51 import net.systemeD.potlatch2.*;
52 import net.systemeD.potlatch2.save.SaveManager;
53 import flash.system.Security;
55 import flash.events.MouseEvent;
56 import flash.display.Sprite;
57 import mx.core.IChildList;
58 import mx.containers.Canvas;
59 import mx.core.Application;
60 import com.yahoo.maps.api.YahooMap;
61 import com.yahoo.maps.api.YahooMapEvent;
62 import com.yahoo.maps.api.core.location.LatLon;
64 public var theMap:Map;
66 private function initApp():void {
68 Globals.vars.map_area=map_area;
69 Globals.vars.root=map_area.rawChildren; // set up global reference to root level
70 var _root:IChildList=map_area.rawChildren; // convenient local shorthand
72 // map backdrop object
73 var w:uint = map_area.width;
74 var h:uint = map_area.height;
75 var b:Sprite = new Sprite();
76 b.height=h; b.width=w;
77 b.graphics.beginFill(0xFFFFEA,100);
78 b.graphics.drawRect(0,0,w,h);
82 /* // Add Yahoo! background
83 var yahoo:YahooMap = new YahooMap();
84 yahoo.init("f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR", w, h);
85 yahoo.mapType="satellite";
86 _root.addChild(yahoo);
89 var yahooListener:Object = new Object();
90 yahooListener.yahooInit=function(event:YahooMapEvent):void {
91 yahoo.zoomLevel = 18-theMap.scale;
92 yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
94 yahooListener.moveHandler=function(event:MapEvent):void {
95 yahoo.zoomLevel=18-event.params.scale;
96 yahoo.centerLatLon=new LatLon(event.params.lat, event.params.lon);
98 theMap.addEventListener(MapEvent.MOVE, yahooListener.moveHandler);
100 yahooListener.resizeHandler=function(event:MapEvent):void {
101 yahoo.setSize(event.params.width, event.params.height);
103 theMap.addEventListener(MapEvent.RESIZE, yahooListener.resizeHandler);
105 yahoo.addEventListener(YahooMapEvent.MAP_INITIALIZE, yahooListener.yahooInit);
108 theMap=new Map(this.loaderInfo.parameters);
110 _root.addChild(theMap);
111 theMap.updateSize(w, h);
114 var s:Sprite=new Sprite();
115 s.graphics.beginFill(0xFFFFFF,100);
116 s.graphics.drawRect(0,0,w,h);
117 s.graphics.endFill();
123 s.graphics.lineStyle(2,0);
124 s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
125 s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
126 s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
127 s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
130 // mouse-up handler attached to stage, so the user can release outside the map
131 stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
132 Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
133 Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
135 // keyboard event attached to stage
136 stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
138 // example listener event
139 var myListenerObj:Object = new Object();
140 myListenerObj.mapHandler=function(event:MapEvent):void {
141 Globals.vars.debug.appendText("Download event fired - "+event.params.minlat+","+event.params.minlon+"\n");
143 theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
146 var t:TextField=new TextField();
147 t.width=500; t.height=150; t.border=true;
150 Globals.vars.debug=t;
151 t.visible = loaderInfo.parameters["show_debug"] == 'true';
152 Globals.vars.root=theMap; // just for the addDebug function
154 var controller:EditController = new EditController(theMap, tagViewer);
155 controller.setActive();
157 var conn:Connection = Connection.getConnectionInstance();
158 conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
159 conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
162 public function onResizeMap():void {
163 if ( theMap != null )
164 theMap.updateSize(map_area.width, map_area.height);
167 private function onDataStart(event:Event):void {
168 dataWorking.text = event.type == Connection.LOAD_STARTED ? "Loading data..." : "Saving Data...";
169 dataWorking.visible = true;
171 private function onDataComplete(event:Event):void {
172 dataWorking.visible = false;