Actionscript object movement

I’m new to the forum, but not to Kirupa. Hi everyone.

I’ve been using the piece of code below to move objects in flash. It works and looks great. However, after placing it on several objects in one fla the movie gets quite sluggish due to the constant iterations. Anyone have any ideas on how I can turn ON the code when i want to move the object, and turn it OFF when the object reaches it’s destination.

onClipEvent (load) {
var a = 2; // acceleration - between 1.1-10
var d = 4; // damping - between 1.1 - 4
var newX = _x;
var myXspeed = 0;

onClipEvent (enterFrame) {
myXspeed = ((_x-newX)/a+myXspeed)/d;
_x -= myXspeed;