checks for access token, and displays OAuth panel if needed
var force_auth:String = loaderInfo.parameters["force_auth"];
if (!conn.hasAccessToken() && force_auth == 'force') {
SaveManager.ensureAccess(onAccessChecked);
}
// show help dialog on startup, if required
// show_help == always => on every startup
// show_help == once => show on first startup only
var show_help:String = loaderInfo.parameters["show_help"];
if (show_help == 'always' || (show_help == 'once' && obj.data["help_shown"] != "true")) {
new HelpDialog().init();
}
// Check if Tiger highlighting should be enabled from saved object
Globals.vars.highlightTiger = obj.data['tiger_highlighted'];
}
public function onMapError(mapEvent:MapEvent):void {
var buttons:uint=0;
if (mapEvent.params.no) { trace("no is set"); }
if (mapEvent.params.yes ) buttons|=mx.controls.Alert.YES;
if (mapEvent.params.no ) buttons|=mx.controls.Alert.NO;
if (mapEvent.params.cancel ) buttons|=mx.controls.Alert.CANCEL;
if (mapEvent.params.ok || buttons==0) buttons|=mx.controls.Alert.OK;
trace("showing alert with "+buttons);
Alert.show(mapEvent.params.message, 'Error', buttons, null, function(closeEvent:CloseEvent):void {
switch (closeEvent.detail) {
case mx.controls.Alert.CANCEL: mapEvent.params.cancel(); break; //fixme? this gets called if user presses escape, even if there's no cancel button.
case mx.controls.Alert.YES: mapEvent.params.yes(); break;
case mx.controls.Alert.NO: mapEvent.params.no(); break;
default: if (mapEvent.params.ok) mapEvent.params.ok();
}
});
}
/** Highlight an entity in response to an 'attention' event */
public function onAttention(event:AttentionEvent):void {
var entity:Entity=event.entity;
if (entity is Relation) {
// If it's a relation, just bring up the editor panel
var panel:RelationEditorPanel = RelationEditorPanel(
PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
panel.setRelation(entity as Relation);
PopUpManager.centerPopUp(panel);
return;
}
var lat:Number, lon:Number;
var panTo:Boolean=true;
if (entity is Way) {
// If it's a way, find if it's on-screen
for (var i:uint=0; i0 && savecount>0) { dataWorking.text="Loading/saving..."; }
else if (loadcount>0) { dataWorking.text="Loading data..."; }
else if (savecount>0) { dataWorking.text="Saving data..."; }
else { dataWorking.text=""; }
dataWorking.visible=(dataWorking.text!="");
}
private function onDataDirty(event:Event):void {
saveButton.enabled=true;
if (ExternalInterface.available) {
ExternalInterface.call("markChanged", false);
}
}
private function onDataClean(event:Event):void {
saveButton.enabled=false;
if (ExternalInterface.available) {
ExternalInterface.call("markChanged", true);
}
}
private function scaleHandler(event:MapEvent):void {
dispatchEvent(new Event("rescale"));
}
[Bindable(event="rescale")]
private function getScale():String {
return String(theMap.scale);
}
private function dragEnterHandler(event:DragEvent):void {
// Get the drop target component from the event object.
var dropTarget:Canvas=event.currentTarget as Canvas;
// Accept the drag only if the user is dragging poi with tags
if (event.dragSource.hasFormat('tags'))
{
DragManager.acceptDragDrop(dropTarget);
}
}
private function dragDropHandler(event:DragEvent):void {
// Deselect the dragged icon
if (event.dragSource.dataForFormat('container')) {
event.dragSource.dataForFormat('container').selectedItem=-1;
}
// Get the tags
var tags:Array = event.dragSource.dataForFormat('tags') as Array;
var mapLoc:Point = Globals.vars.root.globalToLocal(new Point(event.stageX, event.stageY));
var lat:Number = Globals.vars.root.coord2lat(mapLoc.y);
var lon:Number = Globals.vars.root.coord2lon(mapLoc.x);
var createAction:CompositeUndoableAction = new CompositeUndoableAction("Create POI");
var node:Node = Connection.getConnectionInstance().createNode({}, lat, lon, createAction.push);
for each ( var tag:Object in tags ) {
node.setTag(tag.k, tag.v, createAction.push);
}
Connection.getConnectionInstance().registerPOI(node);
MainUndoStack.getGlobalStack().addAction(createAction);
theController.setState(new SelectedPOINode(node));
}
/* Called when forcing an initial access token check. */
private function onAccessChecked():void {
// Floaty panel message "You now have access";
}
private function loadTrace(id:Number):void {
var conn:Connection = Connection.getConnectionInstance();
conn.addEventListener(Connection.TRACES_LOADED, function (e:Event):void {
for each (var trace:Trace in conn.getTraces()) {
if (trace.id == id) { trace.addToMap(); }
}
});
conn.fetchUserTraces();
}
]]>