Draggable Menu (Need Help)

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. :slight_smile: \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 += 3dxdrag ;\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 += 5dxdrag;\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.

Argghh… I’m hurt deep down in my pride… :smiley: \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]

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

 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]

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 but Im not sure if its gonna download properly.\r\rI can mail it to u. Plz send me ur mail address.

No, I’m not the least bitter :smiley: 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]

You sure can Double Post though :slight_smile: ))))))

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

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. :slight_smile:

Thanks for the line thing. It toom me some time…\rCheck that link pub40.ezboard.com/fkirupa…ID=2.topic fot the footers.\rAnd my mail is [email protected]\r\rpom 0]