# Draggable Menu (Need Help)

**URL:** https://forum.kirupa.com/t/draggable-menu-need-help/2880
**Category:** flash
**Created:** [March 18, 2002, 2:13pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880 "2002-03-18T14:13:38Z")
**Posts on this page:** 9
**Page:** 1

<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: [March 18, 2002, 2:13pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/1 "2002-03-18T14:13:38Z")

</div>

I made a few changes to the draggable menu part I to limit the motion of the slider so that it doesnt go beyond a certain limit. Below i am giving the code I have used and the instance names used in it are the same as that of the Draggable Menu Pt I tutorial. My changes work better but why and how they work better…this is something I havent understood. Please try and explain this to me. I will b very greatful. 🙂 \r\rFirst Up the ‘dragger’ button inside the movie clip drag had the following code in the tutorial:\r\ron (press) {\rdragging = 1 ;\r}\ron (release) {\rdragging = 0 ;\r}\r\rI changed this code to :\r\ron (press) {\r&nbsp &nbsp &nbsp &nbsp startDrag ("", true, left, top, right, bottom);\r&nbsp &nbsp &nbsp &nbsp dragging = 1;\r}\ron (release) {\r&nbsp &nbsp &nbsp &nbsp stopDrag ();\r&nbsp &nbsp &nbsp &nbsp dragging = 0;\r}\r\rThen in the root the drag movie had the following code in the tutorial:\r\ronClipEvent (load) {\r&nbsp &nbsp &nbsp &nbsp set (xold, \_x);\r}\ronClipEvent (enterFrame) {\rif (dragging) {\r\_x = \_root.\_xmouse ;\rdxdrag = \_x - xold ;\rxold = \_x ;\r\_root.general.\_x += 3_dxdrag ;\r}\r}\r\rthis I changed to :\r\ronClipEvent (load) {\r&nbsp &nbsp &nbsp &nbsp xold = \_root.general.\_x;\r&nbsp &nbsp &nbsp &nbsp top = \_root.dragger.\_y;\r&nbsp &nbsp &nbsp &nbsp bottom = \_root.dragger.\_y;\r&nbsp &nbsp &nbsp &nbsp left = \_root.dragger.\_x-95;\r&nbsp &nbsp &nbsp &nbsp right = \_root.dragger.\_x+96;\r&nbsp &nbsp &nbsp &nbsp }\ronClipEvent (enterFrame) {\r&nbsp &nbsp &nbsp &nbsp if (dragging) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.general.\_x = xold;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp dxdrag = \_root.dragger.\_x-xold;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp xold = \_root.general.\_x;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.general.\_x += 5_dxdrag;\r&nbsp &nbsp &nbsp &nbsp }\r}\r\r\rThe problem with the code in the tutorial was that \r\ri) the slider was not limited and was allowed to go off limits (out of the movie)\rii) simply clicking the dragger at run time with out dragging it at all the movie clip ‘general’ used to move to the right, just a bit, automatically.\r\rMy code prevents this by firstly adding the startdrag() function with the left, right, top and bottom parameters.\rThe rest of the coding after “onclipevent(enter frame)” is by trial and error. I havent been able to understand why it is working. Please help 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: [March 18, 2002, 8:27pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/2 "2002-03-18T20:27:43Z")

</div>

Argghh… I’m hurt deep down in my pride… 😃 \rOK, so it’s normal that this movie doesn’t work well, because it’s part I, it all gets better in Part II. Secondly, I can’t remember my variables, so let me check.\r\rpom 0]

---

<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: [March 18, 2002, 9:10pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/3 "2002-03-18T21:10:26Z")

</div>

Well, my dear, it works because you’re lucky (feel the bitterness in the voice ???).

```auto
 onClipEvent (load) {\r\r xold = _root.general._x; // that's not correct. dxdrag refers to the amount the dragger moved\r\r top = _root.dragger._y;\r\r bottom = _root.dragger._y;\r\r left = _root.dragger._x-95;\r\r right = _root.dragger._x+96;\r\r }\r\ronClipEvent (enterFrame) {\r\r if (dragging) {\r\r _root.general._x = xold;\r\r dxdrag = _root.dragger._x-xold; // that's why it's illogical to do this\r\r// you calculate the distance between the dragger and the movie clip general, which isn't relevant\r\r xold = _root.general._x;\r\r _root.general._x += 5*dxdrag;\r\r }\r\r}

```

Moreover, the last 4 lines don’t really make sense : the current \_x position is set to \*\* xold\*\*. OK\rThen \*\* dxdrag\*\* is set to the distance between the dragger and the movie clip general. Not OK\rThen \*\* xold\*\* takes the value of the current position of \*\* general\*\*, which is xold since you’ve just done it so.\rYou move \*\* general\*\*. OK.\r\rI’d like to see it work, because your code seems really strange…\r\rpom 0]

---

<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: [March 19, 2002, 2:51pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/4 "2002-03-19T14:51:31Z")

</div>

Hey Pom! Buddy I know youre exceptionally good at flash but that bitterness was uncalled for.\r\rAnyhow, I have been able to partly figure out my code.\r\rxold= original movie position…its same for the dragger (remains constant throughout)\rdxdrag= amount the dragger moves left or right\r\rso when I update\r\_root.general.\_x += 5\*dxdrag;\rI just move the movie 5 times the dragger and it stays put.\r\rI still havent figured out why the movie doesnt revert to its original position when its encounters \r\r\_root.general.\_x = xold;\r\rjust at the starting of the loop.\r\rI have uploaded the fla at [djkunz.tripod.com/drag.fla](http://djkunz.tripod.com/drag.fla) but Im not sure if its gonna download properly.\r\rI can mail it to u. Plz send me ur mail address.

---

<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: [March 19, 2002, 2:58pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/5 "2002-03-19T14:58:49Z")

</div>

No, I’m not the least bitter 😃 Just joking. On the contrary, I’d be glad if you could find a better technique than mine, since I’m not \* exceptionally good at flash\*; lol\rI’ll check your movie.\r\rpom 0]

---

<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: [March 19, 2002, 3:31pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/6 "2002-03-19T15:31:05Z")

</div>

You sure can Double Post though 🙂 ))))))

---

<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: [March 19, 2002, 3:34pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/7 "2002-03-19T15:34:48Z")

</div>

Yeah, but I’m a mod, so nobody will know 😉 \r\rpom 0]

---

<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: [March 19, 2002, 4:53pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/8 "2002-03-19T16:53:29Z")

</div>

Hey Pom this line dot thingy is cooooool.\r\rPlease tell me…whats double post? and how do u guys get your WONDERFUL flash creations in your posts?\r\rThanks so much …still waiting for ur email address incase u havent been able to download the fla otherwise. 🙂

---

<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: [March 19, 2002, 5:16pm UTC](https://forum.kirupa.com/t/draggable-menu-need-help/2880/9 "2002-03-19T17:16:00Z")

</div>

Thanks for the line thing. It toom me some time…\rCheck that link [pub40.ezboard.com/fkirupa…ID=2.topic](http://pub40.ezboard.com/fkirupafrm13.showMessage?topicID=2.topic) fot the footers.\rAnd my mail is [ilyas.usal@club-internet.fr](mailto:ilyas.usal@club-internet.fr)\r\rpom 0]
