# how to converter as2 to as3 rotation attan2

**URL:** <https://forum.kirupa.com/t/how-to-converter-as2-to-as3-rotation-attan2/640147>\
**Category:** flash\
**Created:** [August 7, 2019, 5:46pm UTC](https://forum.kirupa.com/t/how-to-converter-as2-to-as3-rotation-attan2/640147 "2019-08-07T17:46:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anderson\_teixeira](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/anderson_teixeira/32/9811_2.png) [@anderson\_teixeira](https://forum.kirupa.com/u/anderson_teixeira)\
**Post date:** [August 7, 2019, 5:46pm UTC](https://forum.kirupa.com/t/how-to-converter-as2-to-as3-rotation-attan2/640147/1 "2019-08-07T17:46:21Z")

</div>

```
var hip;
var cY , cX;
var aguaIsDragging=false;
var aguaOldX = agua._x;
var aguaOldY = agua._y;
var aguaOldH = agua._height;
var aguaOldW = agua._width;
var angulo:Number;
var mouseListener:Object = new Object();
var a,b;

mouseListener.onMouseMove = function() {

	if(newmouse._x<0)   
		newmouse._x=0;

	if(newmouse._x>800)
		newmouse._x=800;

	if(newmouse._y>467 || newmouse._y <115)
		this.onMouseUp();

	a=agua._y-newmouse._y;
	b=newmouse._x-agua._x;
	angulo= -(Math.atan2(a,b)*(180/Math.PI))+90;

	mangueira._rotation= angulo;
	
	if(aguaIsDragging){
		
		hip=0;
		cY=agua._y-_ymouse;

		if(cX=agua._x>_xmouse)
			cX=agua._x-_xmouse;
		else
			cX=_xmouse - agua._x;

		hip=Math.sqrt((Math.pow(cX,2)+ Math.pow(cY,2)));
		agua._rotation=0;
		agua._height=(int(hip))+50;
		agua._rotation= angulo ;
	}	

};

var intervaloVerific = null;

//Atira 
mouseListener.onMouseDown = function() {

//Pega a ponta da agua acertando
	if(!(newmouse._y >467 || newmouse._y <115)){
		newmouse._visible=false;

		cY=agua._y-_ymouse;
	
		if(cX=agua._x>_xmouse)
			cX=agua._x-_xmouse;
		else
			cX=_xmouse - agua._x;
	
		hip=Math.sqrt((Math.pow(cX,2)+ Math.pow(cY,2)));
		
		
		pontaAgua._visible=true;
	
		aguaIsDragging=true;
	
	     if(intervaloVerific==null)
		intervaloVerific=setInterval(verificaHit,50);
		
		this.onMouseMove();
		
	}

};

mouseListener.onMouseUp = function(){

	pontaAgua._visible=false;
	newmouse._visible=true;
	aguaIsDragging=false;
	agua._rotation = 0;
	agua._height=aguaOldH;
	agua._width=aguaOldW;
	agua._y=aguaOldY;
	agua._x=aguaOldX;
	
	clearInterval(intervaloVerific);
	intervaloVerific=null;
	
	cena.barra1._visible=false;
	cena.barra2._visible=false;

}

Mouse.addListener(mouseListener);
```
