# Point at Mouse Math

**URL:** https://forum.kirupa.com/t/point-at-mouse-math/317550
**Category:** flash
**Created:** [December 24, 2010, 6:42am UTC](https://forum.kirupa.com/t/point-at-mouse-math/317550 "2010-12-24T06:42:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Hoshi](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@Hoshi](https://forum.kirupa.com/u/Hoshi)
#### Post date: [December 24, 2010, 6:42am UTC](https://forum.kirupa.com/t/point-at-mouse-math/317550/1 "2010-12-24T06:42:24Z")

</div>

basically I’m trying to make a movie clip that rotates to point at the mouse. I got the parts of the script to work where the clip rotates when the mouse moves, the problem is the math that goes into finding the angle of rotation  
this is the best Ive managed to come up with so far but the movie clip doesn’t point at the mouse with this, hence a problem

var xDistance:Number = mouseX-this.x  
var yDistance:Number = mouseY-this.y  
var angle:Number = Math.atan2(yDistance, xDistance)\*(180/Math.PI)  
this.rotation = angle

this is just a part of the script (the mathy portion)
