OwlCyberSecurity - MANAGER
Edit File: MovingDocument.as
package { import flash.display.MovieClip; import flash.geom.Point; import flash.geom.Matrix; import flash.filters.DropShadowFilter; import flash.events.Event; import flash.events.MouseEvent; import DynamicMovie; public class Document extends DynamicMovie { private var nMasse:Number = 1; private var pImp:Point = new Point(0,0); private var pCenter:Point = new Point(500,400); private var pOldStageMouse:Point = new Point(0,0); private var nRot:Number = 0; private var nSinOffsetImp:Number = 0; private var dTheta:Number = 100; private var nOffsetMin:Number = 100; private var nResist:Number = 0.7; private var nResistRot:Number = 0.7; private var fShadow:DropShadowFilter = new DropShadowFilter(); private var nHeightShadow:Number = 0; private var nHeightDrag:Number = nHeightShadow+25; private var nScale:Number = 1.2; public function Document():void { fShadow.distance = nHeightShadow; fShadow.alpha = 0.75; this.filters = [fShadow]; this.addEventListener(MouseEvent.MOUSE_DOWN, Drag); this.addEventListener(Event.ENTER_FRAME,Debug); this.buttonMode = true; } private function Drag(event:MouseEvent):void { pOldStageMouse.x = this.mouseX; pOldStageMouse.y = this.mouseY; fShadow.distance = nHeightDrag; this.filters = [fShadow]; this.scaleX = nScale; this.scaleY = nScale; this.parent.setChildIndex(this, this.parent.numChildren-1); this.setRegistration(this.mouseX, this.mouseY); this.removeEventListener(Event.ENTER_FRAME,Inertia); this.removeEventListener(MouseEvent.MOUSE_DOWN, Drag); stage.addEventListener(MouseEvent.MOUSE_UP, Undrag); this.addEventListener(Event.ENTER_FRAME,MoveDoc); } private function Undrag(event:MouseEvent):void { this.removeEventListener(Event.ENTER_FRAME,MoveDoc); this.addEventListener(Event.ENTER_FRAME,Inertia); stage.removeEventListener(MouseEvent.MOUSE_UP,MoveDoc); this.addEventListener(MouseEvent.MOUSE_DOWN, Drag); } private function MoveDoc(event:Event):void { var pLocalMouse:Point = new Point(this.mouseX, this.mouseY); if (pLocalMouse.length < nOffsetMin) { pLocalMouse.normalize(nOffsetMin); } pImp.x = pLocalMouse.x-this.globalToLocal(pOldStageMouse).x; pImp.y = pLocalMouse.y-this.globalToLocal(pOldStageMouse).y; //trace("Impulsion = "+pImp.x+" "+pImp.y); if ((pImp.length!=0)&&(pLocalMouse.length!=0)) { //nSinOffsetImp = (pLocalMouse.x*pImp.y - pLocalMouse.y*pImp.x)/((pImp.length)*pLocalMouse.length); //nRot = ((pImp.length * nSinOffsetImp * dTheta) / (nMasse * pLocalMouse.length)); } else { nRot = 0; } pImp.x = this.stage.mouseX-pOldStageMouse.x; pImp.y = this.stage.mouseY-pOldStageMouse.y; this.x2 = this.stage.mouseX; this.y2 = this.stage.mouseY; this.rotation += nRot; pOldStageMouse.x = this.stage.mouseX; pOldStageMouse.y = this.stage.mouseY; } private function Inertia(event:Event):void { pImp.x*=nResist; pImp.y*=nResist; nRot*=nResistRot; if (fShadow.distance>nHeightShadow) { var nStep:Number = 5; fShadow.distance -= nStep; if (fShadow.distance<nHeightShadow) { fShadow.distance=nHeightShadow; } this.filters = [fShadow]; } this.filters = [fShadow]; if (this.scaleX > 1) { this.scaleX -= 0.04; this.scaleY -= 0.04; } else { this.scaleX = this.scaleY = 1; } if (pImp.length>1) { this.x += pImp.x; this.y += pImp.y; } if (nRot>0.5) { this.rotation += nRot; } if (nRot<0.5&&pImp.length<1&&fShadow.distance==0&&this.scaleX == 1) { this.removeEventListener(Event.ENTER_FRAME,Inertia); } } private function Debug(event:Event):void { trace("Mouse Document = "+mouseX+" "+mouseY); trace("Mouse Stage = "+pOldStageMouse.x+" "+pOldStageMouse.y); trace(" "); } } }