I have the following code for a movie clip to generate random squares and move them around.

onClipEvent (load) {

//data you may want to change

width = 600;

height = 400;

speed = Math.round(Math.random()*2)+1;

//initial positions

x = this._x=Math.random()*width;

y = this._y=Math.random()*height;

x_new = Math.random()*width;

y_new = Math.random()*height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_x*speed;

} else {

x_new = Math.random()

*width;*

}

//y movement

if (y_new>this._y) {

sign_y = 1;

} else {

sign_y = -1;

}

dy = Math.abs(y_new-this._y);

if ((dy>speed) || (dy<-speed)) {

this._y += sign_yspeed;

}

//y movement

if (y_new>this._y) {

sign_y = 1;

} else {

sign_y = -1;

}

dy = Math.abs(y_new-this._y);

if ((dy>speed) || (dy<-speed)) {

this._y += sign_y

} else {

y_new = Math.random()*height;

}

}

this code is on a square which was converted to a movie clip

the timeline frame has this code:

i = 0;

while (i<25) {

//duplicateMovieClip(dot, “dot”+i, i);

dot.duplicateMovieClip(“dot”+i, i);

i++;

}

I would like all the squares to stop moving and fall off the bottom of the window when the user clicks anywhere in the feild. ideas?