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)
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…
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