Wall collision with a scrolling effect

Does anyone know how to make a collision with this script?

onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
scroll = 20;
xspeed = 0;
this._x -= 20;
_root._x += scroll;
}
if (Key.isDown(Key.RIGHT)) {
scroll = 20;
xspeed = 0;
this._x += 20;
_root._x -= scroll;
}
}

Any help would be arrrrrr-preciated!:pirate3: