# Conditional scrolling of infinite menu

**URL:** <https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155>\
**Category:** flash\
**Created:** [September 23, 2004, 1:48pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155 "2004-09-23T13:48:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JP\_West](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@JP\_West](https://forum.kirupa.com/u/JP_West)\
**Post date:** [September 23, 2004, 1:48pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/1 "2004-09-23T13:48:41Z")

</div>

Can I make the scrolling of the infinite menu conditional on the y position of the mouse cursor?

I have fiddled with if functions to no avail, I only want the menu to move when the mouse is positioned within its borders: eg. not elsewhere on the page.

---

<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:** [September 23, 2004, 5:15pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/2 "2004-09-23T17:15:17Z")

</div>

i’m not sure what you have tried exactly but you might try replacing

```auto

 onClipEvent (enterFrame)
{
   var distance=_root._xmouse-xcenter;
   _x+=(distance*speed);
}

```

with

```auto

 onClipEvent (enterFrame){
if (_ymouse>top && _ymouse<bottom){
   var distance=_root._xmouse-xcenter;
   _x+=(distance*speed);
}
}

```

replace top with the y coordinate for the top of the menu and replace bottom with the y coordinate for the bottom of the menu

essentially, i’ve taken the function that tells the menu to move and told it to only happen when the mouse is between the vertical coordinates where the menu is

i hope this helps

---

<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:** [September 24, 2004, 9:08am UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/3 "2004-09-24T09:08:08Z")

</div>

Changed the code slightly to this:

```auto

onClipEvent (enterFrame) {
if (_root._ymouse>60 && _root._ymouse<80) {
var distance = _root._xmouse-xcenter;
_x += (distance*speed);
}
}

```

Works like a charm. On a side note; am I to assume that flash doesnt work with inequalities, because I tried some almost identical code which didnt work.

```auto

onClipEvent (enterFrame) {
if ( 60 < _root._ymouse < 80 ) {
var distance = _root._xmouse-xcenter;
_x += (distance*speed);
}
}

```

Seeing as my inequality means exactly the same as your bit of code, the only reason I can see for it not working is that flash doesn’t recognise inequalitys.

---

<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:** [September 24, 2004, 2:59pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/4 "2004-09-24T14:59:34Z")

</div>

no i’ve used innequalities in flash before, that looks like it should work except for the space between the numbers and the parens, you don’t need that. but i’m glad my code worked for you 🙂

---

<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:** [September 24, 2004, 3:18pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/5 "2004-09-24T15:18:12Z")

</div>

The space is meaningless, I would’ve auto formatted anyway… maybe I put my “if” outside of the onClipEvent handler… silly mistake if that is the case, but thats me for you.

Anyway, thanks… the constant movement of the menu was doing my head in.

---

<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:** [September 24, 2004, 3:20pm UTC](https://forum.kirupa.com/t/conditional-scrolling-of-infinite-menu/65155/6 "2004-09-24T15:20:47Z")

</div>

anytime 🙂 thanks for shopping Kirupa and have a wonderful day
