# AS2 - movieclip jerking when mouse is outside of movie

**URL:** https://forum.kirupa.com/t/as2-movieclip-jerking-when-mouse-is-outside-of-movie/571529
**Category:** flash
**Created:** [March 10, 2015, 1:51am UTC](https://forum.kirupa.com/t/as2-movieclip-jerking-when-mouse-is-outside-of-movie/571529 "2015-03-10T01:51:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Clark\_Magagni](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@Clark\_Magagni](https://forum.kirupa.com/u/Clark_Magagni)
#### Post date: [March 10, 2015, 1:51am UTC](https://forum.kirupa.com/t/as2-movieclip-jerking-when-mouse-is-outside-of-movie/571529/1 "2015-03-10T01:51:53Z")

</div>

I am using this function to attach a movieclip to the mouse (with easing). But when the mouse goes out of the swf inside the browser, on all sides except the left, the movieclip jerks to the utmost left position it can have in the game. I would like it to stay where it is. How to?

```auto
mousecontrol = function() {
	
	mx=_root._xmouse;
	
	if (mx<plat2._x) {
		dx=plat2._x-mx;
	}
	else {
		dx=mx-plat2._x;
	}

	moveSpeedx=dx/3;
	if (mx<plat2._x) {
		plat2._x = plat2._x-moveSpeedx;
	}
	else {
		plat2._x = plat2._x+moveSpeedx;
	}
	
	if (plat2._x<70)
	{plat2._x=70}

	if (plat2._x>600)
	{plat2._x=600}	
}

```

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [March 10, 2015, 11:42am UTC](https://forum.kirupa.com/t/as2-movieclip-jerking-when-mouse-is-outside-of-movie/571529/2 "2015-03-10T11:42:32Z")

</div>

I don’t see anything in your code that would cause this behavior. Is there anything else acting on plat2.\_x?

---

<div class="post-metadata">

### Author: ![Clark\_Magagni](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@Clark\_Magagni](https://forum.kirupa.com/u/Clark_Magagni)
#### Post date: [April 16, 2015, 10:16pm UTC](https://forum.kirupa.com/t/as2-movieclip-jerking-when-mouse-is-outside-of-movie/571529/3 "2015-04-16T22:16:47Z")

</div>

Senocular, sorry for replying so late…I thought I’d say that I confirmed it was an issue specific to Safari, that does not happen in any other browser. It happens when I simply set the \_x of the clip to \_xmouse as well. When the mouse cursor goes outside of the movie, the movieclip simply goes to x = 0. I will simply implement a script to pause the game when the mouse is outside the movie, and make the swf larger. Again, it happens in Safari only; browser specific issue.
