Random Box

I did not write this code, but i cannot find where it’s wrong, so it
doesn not work. It’s just supposed to move a box randomly along
the x axis. Any thoughts?

onClipEvent (load) {
	var limit = 600;
	var rand = random(limit);
	var currentPos = this._x;
	var speed = 5;
}
onClipEvent (enterFrame) {
	if (rand<=currentPos) {
		var count = rand;
		while (count>currentPos) {
			this._x -= speed;
			var count = count-speed;
			//var currentPos = this._x;
		}
	} else {
		var count = rand;
		while (count<currentPos) {
			this._x += speed;
			var count = count+speed;
			//var currentPos = this._x;
		}
	}
}

onClipEvent (load) {
    limit = 600;
    newPos = random(limit);
    speed = 5;
}
onClipEvent (enterFrame) {
    _x += (newPos-_x)/speed
}


onClipEvent (load) {
	limit = 600;
	newPos = random(limit);
	speed = 5;
}
onClipEvent (enterFrame) {
	if (_x<newPos) {
		_x += speed;
	}
	if (_x>newPos) {
		_x -= speed;
	}
}

btw, try to loose the flash 5 syntax :S