package { import flash.display.MovieClip; import flash.display.Shape; import flash.events.MouseEvent; import flash.events.Event; public class Desktop extends MovieClip { var bgImage:Shape = new Shape(); var held = false; public function Desktop() { bgImage.graphics.beginFill("0x330000"); bgImage.graphics.drawRect(-500, -500, 1000, 1000); bgImage.graphics.endFill(); addChild(bgImage); this.useHandCursor = true; addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); addEventListener(MouseEvent.MOUSE_UP, mouseUp); addEventListener(Event.ADDED, added); addEventListener(Event.ENTER_FRAME, enterFrame); } private function enterFrame(event:Event) { if(held) { var photoAngle = Math.atan2(((x + 1000) - x), ((y + 1000) - y)) * (180 / Math.PI); var angle = Math.atan2((stage.mouseX - x), (stage.mouseY - y)); if (angle < 0) angle = 2 * Math.PI + angle; angle *= (180/Math.PI); rotation = angle; } } private function added(event:Event) { x = stage.stageWidth/2; y = stage.stageHeight/2; } private function mouseDown(event:MouseEvent) { //this.rotation = stage.mouseX; held = true; } private function mouseUp(event:MouseEvent) { held = false; } } }