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);