View Full Version : How to make something follow your cursor in flash


darklitch
03-31-2005, 10:27 AM
1.) make a symbol (ctrl + F8)
2.) select movie clip and name it cursor.
3.) draw whatever you want to follow the cursor.
4.) up near the top right hand corner, (sorry, I can't spell) you should see something that says "scene 1____cursor", click on scene 1.
5.) open the library (ctrl + L)
6.) drag cursor onto the stage. It does not matter where it is as long as it is there.
7.) click on what you draged to the stage, make sure it is sellected, and open the actions panel (F9)
8.) paste this code onto the screen:

onClipEvent(enterFrame) {
this._y = _root._ymouse;
this._x = _root._xmouse;
}


That should do it

wojtekk97
02-01-2006, 12:36 PM
Is there any way to limit the movement of the cursor on the screen? I'm just a beginner, so this may be a simple anwer, but it has baffled me for a week now. The only thing I can think of is some kind of limit on the x and y corrdinates.

Thanks for the help.

Chaos_Blader
02-01-2006, 11:18 PM
or Even Easier and more accurate (as far as fps goes)

onClipEvent (load) {
startDrag("", true);
}

and the answer to your question woj,

onClipEvent (load) {
startDrag("", true);
max_x = (( Your max x cordianate here));
max_y = (( Your max y cordianate here));
}
onClipEvent (enterFrame) {
if (this._x == max_x) {
stopDrag();
}
if (this._x == max_y) {
stopDrag();
}
}