Putting a stop to random motion: help!

hi there,

i’m working on my final project for a digital media class, using flash. i have some (movie clip) objects that i’ve programmed for random movements, but i’d like them to stop when the user clicks on them. oddly enough, i can’t find code for this anywhere.

i’m not too flash savvy, but i love to learn new things! code is great, and an explanation would be even more amazing. but i’ll take what i can get. here’s what i have so far:

acceleration = 10
newpos = function () {
ranx = Math.round((Math.random ()*375));
rany = Math.round ((Math.random ()*400));
}
newpos();
this.onEnterFrame = function() {
this._x += ((ranx-this._x)/acceleration);
this._y += ((rany-this._y)/acceleration);
if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
newpos();
}
};

extra info that might be helpful: i’ve placed this code on the first frame of the object’s movie clip timeline, and then placed the movie clip on the first frame of my main timeline.

thank you!