Hello, here is a slight improvement on xNephilimx's code. It will keep the animated object totally within bounds (providing its registration point is in the middle), no matter what the width of the Stage:

onClipEvent (load) {
speed = 10;
xpos = this._x;
}
onClipEvent (enterFrame) {
trace(this._x);
this._x += speed;
if (this._x>=Stage .width-this._width/2 || this._x<this._w idth/2)...