- function Main () 
- { 
- 	stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler); 
- } 
-   
- var destinationX:int = 150; 
- var destinationY:int = 150; 
- var dX:int = 0; 
- var dY:int = 0; 
- var vX:int = 0; 
- var vY:int = 0; 
- var moveSpeedMax:Number = 1000; 
- var rotateSpeedMax:Number = 15; 
- var trueRotation:Number = 0; 
- var decay:Number = 0.98; 
-   
- function enterFrameHandler(event:Event):void 
- { 
- 	updatePosition(); 
- 	updateRotation(); 
- } 
-   
- function updatePosition():void 
- { 
- 	destinationX = stage.mouseX; 
- 	destinationY = stage.mouseY; 
- 	vX += (destinationX - water_drop.x) / moveSpeedMax; 
- 	vY += (destinationY - water_drop.y) / moveSpeedMax; 
-   
- 	vX *= decay; 
- 	vY *= decay; 
-   
- 	water_drop.x += vX; 
- 	water_drop.y += vY; 
- } 
-   
- function updateRotation():void 
- { 
- 	dX = water_drop.x - destinationX; 
- 	dY = water_drop.y - destinationY; 
-   
- 	var rotateTo:Number = getDegrees(getRadians(dX, dY)); 
-   
- 	if (rotateTo > water_drop.rotation + 180) rotateTo -= 360; 
- 	if (rotateTo < water_drop.rotation - 180) rotateTo += 360; 
-   
- 	trueRotation = (rotateTo - water_drop.rotation) / rotateSpeedMax; 
- 	water_drop.rotation += trueRotation; 
- } 
-   
- function getRadians(delta_x:Number, delta_y:Number):Number 
- { 
- 	var r:Number = Math.atan2(delta_y, delta_x); 
- 	if (delta_y < 0) 
- 	{ 
- 		r += (2 * Math.PI); 
- 	} 
- 	return r; 
- } 
-   
- function getDegrees(radians:Number):Number 
- { 
- 	return Math.floor(radians/(Math.PI/180)); 
- }