# Detect Mouse Stop?

**URL:** <https://forum.kirupa.com/t/detect-mouse-stop/184856>\
**Category:** flash\
**Created:** [April 8, 2006, 3:18pm UTC](https://forum.kirupa.com/t/detect-mouse-stop/184856 "2006-04-08T15:18:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![onemhunki](https://avatars.discourse-cdn.com/v4/letter/o/c57346/32.png) [@onemhunki](https://forum.kirupa.com/u/onemhunki)\
**Post date:** [April 8, 2006, 3:18pm UTC](https://forum.kirupa.com/t/detect-mouse-stop/184856/1 "2006-04-08T15:18:08Z")

</div>

Folks, I have the following code on a movie clip which follows the mouse fine on the x axis, but does anyone how I can modify it to detect when the mouse has stopped, then the object (a bird) will then stop it’s running action?

```auto

onClipEvent (load) {
	_x = 0;
	speed = 5;
}
onClipEvent (enterFrame) {
	endX = _root._xmouse;
	_x += (endX-_x)/speed;
	
	checkX = function (dx, oldVal, newVal) { 
	if (oldVal<newVal) {
		this._xscale=+100;

	} else if (oldVal>newVal) {
		this._xscale=-100;
	} 
	return newVal;
};

	this.watch("xdir", checkX);
	this.onMouseMove = function() { 
	xdir = _root._xmouse;
};
	
}

```

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 8, 2006, 3:40pm UTC](https://forum.kirupa.com/t/detect-mouse-stop/184856/2 "2006-04-08T15:40:07Z")

</div>

Try to add this to your enterFrame event…

```auto
if(oldX==_root._xmouse) {
    trace("mouse didnt move");
}
oldX = _root._xmouse;

```
