# Center a mc with limits

**URL:** <https://forum.kirupa.com/t/center-a-mc-with-limits/229604>\
**Category:** Uncategorized\
**Created:** [June 18, 2007, 10:13pm UTC](https://forum.kirupa.com/t/center-a-mc-with-limits/229604 "2007-06-18T22:13:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alesspunk](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@alesspunk](https://forum.kirupa.com/u/alesspunk)\
**Post date:** [June 18, 2007, 10:13pm UTC](https://forum.kirupa.com/t/center-a-mc-with-limits/229604/1 "2007-06-18T22:13:13Z")

</div>

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 !!

```php

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);
 }
}

```
