# Centering until a certain x value

**URL:** <https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379>\
**Category:** Uncategorized\
**Created:** [June 25, 2008, 4:01pm UTC](https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379 "2008-06-25T16:01:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 25, 2008, 4:01pm UTC](https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379/1 "2008-06-25T16:01:04Z")

</div>

Im stumped, I know theres probably a simple solution but it’s escaping me at the moment.

I have a centered swf, I want it to stop centering if the swf reaches the side nav so they dont overlap.

function Center(mc) {  
mc.onEnterFrame = function() {  
if(mc.\_x \>500){  
mc.\_x = Stage.width/2;  
mc.\_y = Stage.height/2;

```
	}
};

```

}

this stops the centering when it hits 500, but it stops all centering because it’s stuck on 500.

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 25, 2008, 4:04pm UTC](https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379/2 "2008-06-25T16:04:04Z")

</div>

what about this?

```auto

function Center(mc)
{
	mc.onEnterFrame = function()
	{
		if (mc._x > (nav._x + nav._width))
		{
			mc._x = Stage.width / 2;
			mc._y = Stage.height / 2;
		}
	};
}

```

---

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 25, 2008, 4:08pm UTC](https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379/3 "2008-06-25T16:08:43Z")

</div>

ill try that, but i dont thin it’ll work either.

its going to get stuck on that specific value.

---

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 26, 2008, 1:29pm UTC](https://forum.kirupa.com/t/centering-until-a-certain-x-value/264379/4 "2008-06-26T13:29:48Z")

</div>

any ideas people?
