# Movie clip angle detection?

**URL:** <https://forum.kirupa.com/t/movie-clip-angle-detection/220215>\
**Category:** flash\
**Created:** [March 23, 2007, 6:40pm UTC](https://forum.kirupa.com/t/movie-clip-angle-detection/220215 "2007-03-23T18:40:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![superbungalow](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@superbungalow](https://forum.kirupa.com/u/superbungalow)\
**Post date:** [March 23, 2007, 6:40pm UTC](https://forum.kirupa.com/t/movie-clip-angle-detection/220215/1 "2007-03-23T18:40:36Z")

</div>

I have the following code which detects the mouse angle, relative to a holder movie clip, and then makes the rotation of a “turret” movie clip follow the mouse. How can I adapt it for use with another movie clip in place of the mouse?

```auto

onClipEvent (mouseMove) {
    x = this._xmouse;
    y = this._ymouse*-1;
    angle = Math.atan(y/x)/(Math.PI/180);
    if (x<0) {
        angle += 180;
    }
    if (x>=0 && y<0) {
        angle += 360;
    }
    _root.turret._rotation = (angle*-1) + 90
}

```
