# MC move on mouse location?

**URL:** <https://forum.kirupa.com/t/mc-move-on-mouse-location/319718>\
**Category:** flash\
**Created:** [March 2, 2011, 3:16pm UTC](https://forum.kirupa.com/t/mc-move-on-mouse-location/319718 "2011-03-02T15:16:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![izzo101](https://avatars.discourse-cdn.com/v4/letter/i/c6cbf5/32.png) [@izzo101](https://forum.kirupa.com/u/izzo101)\
**Post date:** [March 2, 2011, 3:16pm UTC](https://forum.kirupa.com/t/mc-move-on-mouse-location/319718/1 "2011-03-02T15:16:14Z")

</div>

Trying to figure out how to make a movieclip move base on mouse location similar to the one seen in [http://www.tcm.com/2011/31Days/index.jsp](http://www.tcm.com/2011/31Days/index.jsp). I’ve found some script that I’ve been working with and it rotates the Y just fine but keeps rotating. How would I determine a set rotation to stop when I stop mouse movement. Here is my script:

var maxSpeed:uint = 1

box.addEventListener(Event.ENTER\_FRAME, onLoop, false, 0, true);

function onLoop(e:Event):void{

```
box.y = stage.stageHeight / 2;

var midPt:uint = stage.stageWidth / 2;

var diff:int = mouseX - midPt;

var perc:Number = diff / midPt;

box.rotationY += perc * maxSpeed;

```

}

Any suggestions?
