# \[CS3,AS2,FuseKit\] Help with switching mouse move event on/off

**URL:** <https://forum.kirupa.com/t/cs3-as2-fusekit-help-with-switching-mouse-move-event-on-off/237567>\
**Category:** flash\
**Created:** [August 31, 2007, 2:43pm UTC](https://forum.kirupa.com/t/cs3-as2-fusekit-help-with-switching-mouse-move-event-on-off/237567 "2007-08-31T14:43:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fallofftheWALL](https://avatars.discourse-cdn.com/v4/letter/f/fbc32d/32.png) [@fallofftheWALL](https://forum.kirupa.com/u/fallofftheWALL)\
**Post date:** [August 31, 2007, 2:43pm UTC](https://forum.kirupa.com/t/cs3-as2-fusekit-help-with-switching-mouse-move-event-on-off/237567/1 "2007-08-31T14:43:10Z")

</div>

Hi everyone, my first post here but here goes…

I have a mouse trailer that lets the user smear paint splats over the stage area. The trailer works fine stand alone, but when I attach a listener to give the user the option to turn the trailer on/off via a pair of buttons, the trailer turns on/off but now fails to follow the mouse cursor! DOH!

Here’s the trailer code…  
(I’ve attached the CS3 file just in case)

```auto

i = 0;
onMouseMove = function() {
	var cur_x = _xmouse;
	var cur_y = _ymouse;
	var limit = 4;
	var min = .5;
	var max = 40;
	var alfa = 160;
	var delta_x = old_x-cur_x;
	var delta_y = old_y-cur_y;
	var dist = Math.sqrt(delta_x*delta_x+delta_y*delta_y);
	old_x = cur_x;
	old_y = cur_y;
	if (dist>limit) {
		i++;
		attachMovie("splatMC","splatMC"+i,-510+i);
		with (this["splatMC"+i]) {
			var ran = Math.random()*max+min;
			var ran2 = Math.random()*alfa-alfa/2;
			_rotation = ran2;
			_xscale = _yscale=ran;
			_x = _parent._xmouse;
			_y = _parent._ymouse;
		}
	}
};
stop();

```

and here’s the trailer code with the listener attached…

```auto
i = 0;
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
	var cur_x = _xmouse;
	var cur_y = _ymouse;
	var limit = 4;
	var min = .5;
	var max = 40;
	var alfa = 160;
	var delta_x = old_x-cur_x;
	var delta_y = old_y-cur_y;
	var dist = Math.sqrt(delta_x*delta_x+delta_y*delta_y);
	old_x = cur_x;
	old_y = cur_y;
	if (dist>limit) {
		i++;
		attachMovie("splatMC","splatMC"+i,-510+i);
		with (this["splatMC"+i]) {
			var ran = Math.random()*max+min;
			var ran2 = Math.random()*alfa-alfa/2;
			_rotation = ran2;
			_xscale = _yscale=ran;
			_x = _parent._xmouse;
			_y = _parent._ymouse;
		}
	}
	updateAfterEvent();
};
stop();

```

Sorry if it’s painfully obvious what the problem is, but I’m a designer rather than a hardcore code monkee!:puzzled:

Thanx in advance
