PDA

View Full Version : [FMX] Following mouse only on Y axis...



mdipi
November 29th, 2002, 01:37 PM
hey guys! I finally got around to starting mdipiV2 but am now running into a problem.

I want the menu to follow the mouse, but only up and down. I just can't figure out the code. so far is a simple start drag, in and onClipEvent handler... i can't figure what to use..._y, or _ymouse. and where do i put it?

thanks in advance,
mike

MP5SD
November 29th, 2002, 02:09 PM
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}

just remove the _y values or the _x for what ever motion u want for example

onClipEvent (load) {
_x = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
}

this would make the movie clip folow the mouse only on the _x axis at speed (5)

I use the same code in my Footer (see below)

eyeinfinitude
November 29th, 2002, 02:30 PM
Or if you're feeling lazy and don't wanna deal with the actionscripting then you can use Flash MX's mouse follow component. I had to modify the AS a little on the component to make it follow the mouse just on the y axis cause the original had the object follow your mouse in all directions. I attached a fla for you to play with. Hope it helps. =)

mdipi
November 29th, 2002, 04:14 PM
elec that was perfect! thank you both! one :q: where can i dl the component?

eyeinfinitude
November 29th, 2002, 04:18 PM
I found the component by accident actually from a fla I got off the net awhile back, but I dont remember where i got it from. You can just copy the component from my sample fla and paste it onto your movie, just change the target names in the component's parameters. Or you can just give your menu an instance name of "followClip" since my sample component is already targeting that instance name. Hope that helps. =)

mdipi
November 29th, 2002, 04:49 PM
belive me it did! i knew how to work it, i just wanted to know if i could down load it so it was in my components list. After using this i relized that i is easyer to just have it still, lol. Well its off to finish this up. I like the final design, and i am doing alot in DW as well. I cant wait to see the finished product! i will love it for a day, then hate it. lol, :P

eyeinfinitude
November 29th, 2002, 04:53 PM
I remember reading from somewhere that components like this comes in a set with other useful components too, but I forgot the name of it. Oh well. :-\ Good luck.

h88
November 29th, 2002, 04:57 PM
Macromedia DRK got really cool set of components. For only $100 US.

eyeinfinitude
November 29th, 2002, 05:01 PM
Yeah!! thats the name of it!! I just couldnt recall what it was. The follow mouse component is just one of the many great components in that set. Thanks h88, I will definitely invest in that set after I gather 10,000 pennies. =)

lostinbeta
November 29th, 2002, 05:04 PM
Hmmm is it just being lazy when you have to download a file and use the component... or just copying and pasting this code on the object??


onClipEvent (load) {
_x = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endY = _root._ymouse;
_y += (endY-_y)/speed;
}


Interesting thought.......

h88
November 29th, 2002, 05:08 PM
I agree with u lost, components are needed for complicated jobs, not for something like easing. :-\

Well, DRK got many complicated ones, ie: DataGrid, Calender, ...
Developers better buying these components, it would save alot of time while coding.

eyeinfinitude
November 29th, 2002, 05:08 PM
You're right Lost, it would be easier to just copying the code and pasting it, but I tend to do things the hard way. A habbit I need to kick to the curb. But thanks for the code though, I'm gonna save it to a text file for future references. =)

lostinbeta
November 29th, 2002, 05:10 PM
Or you could just visit the tutorial at kirupas site...lol.

I tend to do things the hard way as well, but with easing, I didn't think there was a hard way...lol.

mdipi
November 29th, 2002, 09:32 PM
i have memorized the easing thing lol, well the code from bit's tut! its really simple! :P. I just didnt know how to minipulate it...