# Not infinite menu

**URL:** <https://forum.kirupa.com/t/not-infinite-menu/21531>\
**Category:** flash\
**Created:** [May 22, 2003, 6:29pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531 "2003-05-22T18:29:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipegm](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@felipegm](https://forum.kirupa.com/u/felipegm)\
**Post date:** [May 22, 2003, 6:29pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/1 "2003-05-22T18:29:13Z")

</div>

I ´ve learned how to do an infinite menu, but for my project, it would be better if the menu stopped at the end instead.

I´ve read about infinite menu on  
[http://www.kirupa.com/developer/mx/infinite.htm](http://www.kirupa.com/developer/mx/infinite.htm)

I´ve searched around kirupa but found nothing.

Any help?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 22, 2003, 6:35pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/2 "2003-05-22T18:35:59Z")

</div>

if(yourmc.\_x \<= mcx1) {  
yourmc.\_x = mcx1;  
}  
if(yourmc.\_x \>= mcx2) {  
yourmc.\_x = mcx2;  
}

replace “yourmc” with the instance name of the menu-movieclip. (or deleted it if the code is assigned on the menu itself)  
and change mcx1 to the \_x position of the menu where you don’t want it to scroll ot the left anymore! |\<—  
and mcx2 to the \_x position of the menu where you don’t want it to scroll to the right anymore! —\>|

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 22, 2003, 6:59pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/3 "2003-05-22T18:59:14Z")

</div>

I inserted the script you provided, but it didn´t work.  
I´m using this script on the MC:

onClipEvent (load)  
{  
xcenter=150;  
speed=1/10;  
}  
onClipEvent (enterFrame)  
{  
var distance=\_root.\_xmouse-xcenter;  
\_x+=(distance\*speed);  
}

Now where should I insert the code you gave me?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 23, 2003, 4:39am UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/4 "2003-05-23T04:39:46Z")

</div>

put it within he onClipEvent(enterFrame) handlers!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 23, 2003, 5:31am UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/5 "2003-05-23T05:31:39Z")

</div>

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=14049](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=14049)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 23, 2003, 1:44pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/6 "2003-05-23T13:44:22Z")

</div>

long time no see lost…

i have another alternative for this…

```auto
MovieClip.prototype.slideX = function(endPosx) {
	this.onEnterFrame = function() {
		if (this._x<=endPosx) {
			currentPosx = this._x;
			diffPosx = endPosx-currentPosx;
			movex = diffPosx/3;
			this._x = this._x+movex;
			if (this._x>=endPosx) {
				this._x = endPosx;
				this.onEnterFrame = null;
			}
		}
		if (this._x>=endPosx) {
			currentPosx = this._x;
			diffPosx = endPosx-currentPosx;
			movex = diffPosx/3;
			this._x = this._x+movex;
			if (this._x<=endPosx) {
				this._x = endPosx;
				this.onEnterFrame = null;
			}
		}
	};
};

```

that’s for my prototype…

```auto
//holder is my MC
var startPos = holder._x;
//rectMask is the maskMC
var d = holder._width-rectMask._width;
var const = d/rectMask._width;
this.onMouseMove = function() {
	var endPos = (_xmouse-startPos)*(const);
	if (rectMask.hitTest(_xmouse, _ymouse, false)) {
		holder.slideX(-endPos+startPos);
	}
};

```

and that is for the action…

hope it helps…🙂

> i’ll be gone for a while, so can’t help u after this…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 23, 2003, 2:45pm UTC](https://forum.kirupa.com/t/not-infinite-menu/21531/7 "2003-05-23T14:45:02Z")

</div>

Hi

In the case of an infinite menu. Can I make the xcenter to be widther than just a number? Make it be from 130 to 170 so it´s easier for the user to stop the menu?

The code I´m using is:

onClipEvent (load) {  
xcenter = 150;  
speed = .3/10;  
}  
onClipEvent (enterFrame) {  
var distance = \_root.\_xmouse-xcenter;  
\_x += (distance_speed);  
}  
onClipEvent (load) {  
if (\_x\<=10) {  
\_x =10;  
}  
if (\_x\>=300) {  
\_x = 300;  
}  
}  
onClipEvent (enterFrame)  
{  
var distance=\_root.\_xmouse-xcenter;  
\_x+=(distance_speed);  
if (\_x \> 0) \_x=-300;  
if (\_x \< -300) \_x=0;  
}

thanks
