PDA

View Full Version : Move a mc if _ymouse is < 50



thorseye
January 19th, 2003, 04:35 PM
Hellooo
I want to do this: When the mouse is between two y-coordinates, let's say 40 and 50, a movieclip is supposed to be moved. How should I do this? I can move the movieclip by clicking on a button but how do I do this one? And where should the code be put? I thought that this code would work if I put it in the first frame, but it's not..

if (_root._ymouse < 55) {
newpos = 100;
}
Please help...

thorseye
January 19th, 2003, 04:37 PM
Haha.. Never mind.. I put the code in an empty mc inside a onClipEvent(enterFrame) action and tadaa! =)

andr.in
January 19th, 2003, 04:39 PM
you have to make a 2-frame-loop or put the actions on a movieclip within the onClipEvent(enterFrame) handlers!

2-frame-loop:
put the actions in the first frame and make another keyframe in frame 2 and add the action:
gotoAndPlay(1);
on the second keyframe so it will go to the 1st frame, then the 2nd and then the first on again!

or

movieclip:
put the actions on a movieclip like this:

onClipEvent(enterFrame) {
if (_root._ymouse < 55) {
newpos = 100;
}
}


onClipEvent(enterFrame)
enterframe triggers the actions within the handlers every frame! [ so if your fps is 20 the actions will be triggered 20 times per second ]

:)

thorseye
January 19th, 2003, 04:44 PM
yupp.. As I wrote before I did like you said.. Thanks anyway for a quick answer!! =)