Adobe Photoshop Tutorials | Flash Tutorials | 3D Studio Max Tutorials
Home Photoshop | Flash | 3D | Tools | Articles | Directory | Links Link to Us | Contact Us
- Flash Tutorials - Mouse Follower Tutorial - Part 1 - By: Chad Freiling

Mouse Follower in Flash Tutorial

- Part 1
First thing to do is to setup the stage and layers. After we have this done, we'll move on to creating the Movie Clip (MC).

For the tutorial we'll make the Stage 400 x 300, with a fps (frames per second) of 12, which is standard. Background color can stay white.

Now for the Layers.

Default, you start with 1 layer, which is named Layer 1.

Lets make 1 New Layer. To do this press the New Layer Button. So now we have
Layer 2
Layer 1

Rename Layer 2 to "Actions".
and Layer 1 to "Ball"

Next, we create the MC called Ball

Select the "Ball" layer and Create a small Circle or some other type of shape.

The Select the what you created and go to
INSERT > Convert to Symbol

And rename it to "ball" and make sure the Movie Clip is Selected.
Then Click on OK.

With the ball MC selected, change the Instance Name to ball.
While the ball MC is still selected lets add the actionscript to it. Right Click on the ball and select Actions.

In the Top Right corner of the Actions window click on the View Options and Select "Expert Mode". Then Copy and paste the code to the right into the Actions Box.

onClipEvent (enterFrame) {
      // Sets Property of 'ball' to where the mouse is
(this, _x, _root.mousex);
(this, _y, _root.mousey);
Now, Select the first Frame for the Actions layer, Then right click on the frame and choose Actions. Then Copy and Paste the Code to the right into the Actions box. // Gets the current mouse pointer x and y values
// Then places them in stored varible called: mousex or mousey
_root.mousex  = getProperty(_root,_xmouse);
mousey  = getProperty(_root,_ymouse);
So, next thing is to add a 2nd frame for both of the Layers. To do this Select Frame 2 on both layers, then right click and select Insert Frame. After that make sure only Frame 2 of Actions is selected and right click on frame 2 and select Insert Keyframe.
With Frame 2 of Actions selected place a gotoAndPlay(1); action. So that once it reaches frame 2 it replays.
To the right is what your finished timeline should look like.

Press ENTER+CTRL to test the movie.

- Advertisement
- Part 2
Side Note: You can also achive this effect with using the drag function found under Actions > Movie Clip Control > startDrag.

With this effect you can create a few different effects and styles of Followers. With just by adding an MC that has animation you can create great effects. Thank again for doing this tutorial, If you have any questions please let me know.
Home Copyright © 2003 - 2005, Tutorials Network. All Rights Reserved. | Advertise | Privacy Policy