Center a mc with limits

Hi im new here!

i created a hit test for stop a mc on the top of the stage.

It 's blocking all right, but i need that when is blocked then align on the center again.

This is my script*!*

tks a lot !!


onClipEvent (load) {
 speed = 7;
}
onClipEvent (enterFrame) {
 if (_root.container, hitTest(_root.block)) {
  _y = height
 } else {
  centerY = Stage.height/2-330;
  _y = _y+Math.round((centerY-_y)/speed);
 }
}