Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Mouse Follower in Flash
Your Ad Here

Mouse Follower in Flash

Browse Pages: 2  > >>

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.

image 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"

image 2

Next, we create the MC called Ball

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

image 3

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.

image 4

With the ball MC selected, change the Instance Name to ball.

image 5

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
      setProperty(this, _x, _root.mousex);
      setProperty(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);
_root.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.

image 6

With Frame 2 of Actions selected place a gotoAndPlay(1); action. So that once it reaches frame 2 it replays.

image 7

To the right is what your finished timeline should look like.

Press ENTER+CTRL to test the movie.

image 8

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.



Author's URL: Chad Freiling
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
Browse Pages: 2  > >>
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Mouse Follower in Flash"

Only registered users can write comment

No comments yet...