# Mouse trailer with confined area

**URL:** <https://forum.kirupa.com/t/mouse-trailer-with-confined-area/243444>\
**Category:** flash\
**Created:** [November 7, 2007, 3:09am UTC](https://forum.kirupa.com/t/mouse-trailer-with-confined-area/243444 "2007-11-07T03:09:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abrigade](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@abrigade](https://forum.kirupa.com/u/abrigade)\
**Post date:** [November 7, 2007, 3:09am UTC](https://forum.kirupa.com/t/mouse-trailer-with-confined-area/243444/1 "2007-11-07T03:09:39Z")

</div>

I’m trying to modify a mouse trailer I’ve found somewhere else so that it only reacts within a specific area on the flash page - say an area 780x549 on a 1024x700 flash file.

Here is the code I am starting with - The file is written in AS2 for Flash 8+

//mouseTrailer  
i=0  
onMouseMove = function () {  
var cur\_x = \_xmouse;  
var cur\_y = \_ymouse;  
var limit = 3;  
var min = 30;  
var max = 60;  
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(“ball”, “ball”+i, -510+i);  
with (this[“ball”+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;  
}  
}  
};

Can anyone please lend a hand? Thank you very much in advance!
