# \[F8/AS2\] Stopping a scrolling MC at a certain X

**URL:** <https://forum.kirupa.com/t/f8-as2-stopping-a-scrolling-mc-at-a-certain-x/290084>\
**Category:** flash\
**Created:** [June 9, 2009, 3:06pm UTC](https://forum.kirupa.com/t/f8-as2-stopping-a-scrolling-mc-at-a-certain-x/290084 "2009-06-09T15:06:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![birdboy0103](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@birdboy0103](https://forum.kirupa.com/u/birdboy0103)\
**Post date:** [June 9, 2009, 3:06pm UTC](https://forum.kirupa.com/t/f8-as2-stopping-a-scrolling-mc-at-a-certain-x/290084/1 "2009-06-09T15:06:03Z")

</div>

Hey guys, I have a little bit of a problem:

I have a sideways scrolling movieclip that is wider than the stage, but it won’t stop when it reaches the right edge of the stage itself.

Here’s the code:

```auto
_root.onEnterFrame = function() {
	zigScroll_mc._x += Math.cos((-_root._xmouse/Stage.width)*Math.PI)*15;
	if (zigScroll_mc._x>(-1*_parent._parent.data_mc._x)) {
		zigScroll_mc._x = (-1*_parent._parent.data_mc._x);
	}
	if (zigScroll_mc._x ==(-zigScroll_mc._width+(Stage.width-_parent._parent._x))) {
		zigScroll_mc._x = (-zigScroll_mc._width+(Stage.width-_parent._parent._x));
	}

```

I should mention that the part where you see \_parent.\_parent is because the scrolling part is nested within 2 movieclips, and that data\_mc is not at \_x=0

can anyone give me a hand?

Thanks,  
Andrew
