slash and burn trace statements, and fix areas on vector background layers
[potlatch2.git] / net / systemeD / potlatch2 / controller / DragBackground.as
1 package net.systemeD.potlatch2.controller {
2         import flash.events.*;
3     import net.systemeD.potlatch2.EditController;
4     import net.systemeD.halcyon.connection.*;
5     import net.systemeD.halcyon.MapEvent;
6         import net.systemeD.halcyon.Globals;
7
8     public class DragBackground extends ControllerState {
9
10         private var downX:Number;
11         private var downY:Number;
12         
13         public function DragBackground(event:MouseEvent) {
14             downX = event.localX;
15             downY = event.localY;
16         }
17  
18        override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
19
20             if (event.type==MouseEvent.MOUSE_UP) {
21                 return previousState;
22
23                         } else if ( event.type == MouseEvent.MOUSE_MOVE) {
24                                 // dragging
25                                 controller.map.nudgeBackground(event.localX-downX, event.localY-downY);
26                     downX = event.localX;
27                     downY = event.localY;
28                                 return this;
29
30                         } else {
31                                 // event not handled
32                 return this;
33                         }
34         }
35
36         override public function enterState():void {
37                         controller.map.draggable=false;
38                         Globals.vars.root.addDebug("**** -> "+this);
39         }
40         override public function exitState(newState:ControllerState):void {
41                         controller.map.draggable=true;
42                         Globals.vars.root.addDebug("**** <- "+this);
43         }
44         override public function toString():String {
45             return "DragBackground";
46         }
47     }
48 }