# Mouse Angle

**URL:** <https://forum.kirupa.com/t/mouse-angle/286643>\
**Category:** flash\
**Created:** [April 18, 2009, 6:39am UTC](https://forum.kirupa.com/t/mouse-angle/286643 "2009-04-18T06:39:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nav\_sonu](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@nav\_sonu](https://forum.kirupa.com/u/nav_sonu)\
**Post date:** [April 18, 2009, 6:39am UTC](https://forum.kirupa.com/t/mouse-angle/286643/1 "2009-04-18T06:39:59Z")

</div>

Hi, Wanna learn how to get angle of mouse its very simple.  
use this Script (copy and past in your file). A sample file which runs only on CS4 is attached.

//Start…  
// Make a line (o-----------------------) and take its left side as center named ‘mcArrow’  
mcArrow.\_x = mcArrow.\_y =200;

this.onEnterFrame = function(){  
//To make script easier we make ‘x’ and ‘y’ values of center of the stage ‘zero’  
xmouse=200-\_xmouse;  
ymouse=200-\_ymouse;  
//As we know that to get angle ‘Tangent’ is used (which is in radians) to convert it into degree it will be multiplied by 180/pi  
angle = Math.atan(ymouse/xmouse)\*(180/Math.PI);

```
if(xmouse&gt;=0){angle+=180}
mcArrow._rotation = angle;

```

///////////////////////////////////////////////////////  
// we know that in right angle triangle r^2 = x^2 + y^2  
r = Math.sqrt(Math.pow(xmouse,2)+Math.pow(ymouse,2));  
mcArrow.mcLine.\_width = r;  
}

[//nav\_sonu@hotmail.com](https://nav_sonu@hotmail.com), Call me +92-333-6707120
