First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: V. Ramraj | Website: http://www.geocities.com/ramraj_1999
  1. Now we need to create the main movieclip. Press 'Ctrl+F8' and type the name as flyin. Leave the behaviour as the default - Movieclip itself. Click OK.
  2. Now drag the spark movieclip from the Library panel to some place near the plus sign in the stage. This need not be accurate. You can place the clip anywhere on the stage.
  3. Press 'Ctrl+I' to invoke the Instances Panel. In the Name field, give the name of the instance as 'MouseFollower'.
  4. Click on Frame 20. Press F5 to insert frames upto 20. Now click Insert menu - Layer. Click on the First frame of the newly created layer. Press F6 19 times to convert all the frames in layer 2 into keyframes.
  5. Click on Frame 1 of Layer 2. Invoke the Frame Actions panel and convert it to Expert mode as explained earlier. Enter the following code in the panel:
    setProperty ("/sparks/MouseFollower", _visible, false);
    startDrag ("MouseFollower", true);
    icount = 0;
    rotValue = 0;
    degCount = 0;
    tester = 1;
    function MouseTrails ()
    	if (iFireCount>75)
    		iFireCount = 0;
    	duplicateMovieClip ("MouseFollower", "MouseFollower" & iFireCount, iFireCount);
    	MouseFollower._alpha = 100;
    	degCount = degCount+random(20);
    	if (degCount>360)
    		degCount = random(10);
    	MouseFollower._rotation = degCount;
    	tellTarget ("MouseFollower" & iFireCount)
    		set (Me, "MouseFollower" & ../../:iFireCount);
    Here you will find the explanation for the above code. You can skip this if you don't want to understand anything.
    The first line makes the mousefollower movieclip invisible, temporarily.
    The second line tells the player that the mousefollower movieclip moves along with the mouse.
    The lines 3,4,5 and 6 initialize variables that will be used below.
    All the above code will be executed only once. The following code will be nested inside a function and executed in every frame again and again.

    Inside the function, it is first checked if the iFireCount variable is less than 75. This variable keeps track of the number of instances of the mousefollower movieclip that are present in the stage at any given point. It also gives a way of uniquely reffering to any instance at any time.
    The iFireCount variable also is incremented each time this function is executed.

    We then duplicate the MouseFollower movieclip. We name it as MouseFollower followed by an index number, the iFireCount variable. The last parameter of the duplicateMovieClip function specifies the layer of the duplicated movieclip - it determines which instance stays above which instance.
    Since the main parent MouseFollower movieclip is always under the mouse, the new instance stays at the position of the mouse. But if the mouse is moved after the creation, it will not move, because we did not give the startdrag property for the created instance.

    Now the mousefollower movieclip is made visible.

    All the above clip will only duplicate the movieclip. It will not rotate the duplicates to produce the effect we need. So, we need another variable which will be incremented each time and will be set as the value for rotation of each instance. To add some randomness, we give a random incrementation. So, at one time, two instances can be closely spaced, while at other times, they may be farther from each other.
    We also ensure that the value of degCount does not go above 360 degrees.

    At last, we tell each instance of the MouseFollower MovieClip that the variable 'Me' refers to itself, so that it can easily remove itself as soon as it finishes playing. It's sort of killing yourself as soon as your job is over.

    And then we say that the cursor is hidden, to produce a cool effect.
  6. Now enter the following code in all the other frames following frame 1 in layer 2, after converting the 'Frame Actions' panel to Expert mode:
    In the last frame alone, include this extra line:
    Here is a tip. When you are creating a movie of your own, which has just 2 frames, so that there is a loop, you can optimize it so that it plays faster. To do so, just insert the code that you want to repeat again and again in a function and call this function in every frame and after 10 frames, use a gotoAndPlay method to go back to the second frame. This is done because, gotoAndPlay methods or loops take a longer time to play, and reduce the frame rate drastically. You can try it out here itself. Include the statement gotoAndPlay(2); in the 3rd frame's script itself. You can see that it will slow down the movie.
  7. Click Modify menu - Scene. This opens the Scene Panel. Click Scene 1 to go to the main Scene. Drag the flyin movieclip from the Library to the middle of the Scene. Now click in frame 1 and enter the following code in the actions panel after converting it to expert mode.
    setProperty ("/sparks/MouseFollower", _alpha, 0);
    fscommand ("fullscreen", true);
    stop ();

And voila! youre finished! Save the .fla file and publish it to see the fruits of your hard work.

Thanks very much for having the patience to go through this tutorial. I hope that this tutorial will be a valuable addition to your knowledge base in flash.

No one is perfect and I know I am no good at that. I found that I had commited a lot of mistakes in my Tutorial. All you Flash fathers out there, I will be the happiest person if you were able to spot them and send them to by mail to ramraj_1999@yahoo.com. Suggestions and new ideas are also welcome.

And if you have not yet checked it out, visit my 3D Flower tutorial in the 3d section of tutorials in Flashkit.com. It is even more difficult and challenging.

Many of you mailed me requesting me to send you the .fla file for the tutorial when I posted 3d Flower. But incase you haven't noticed it, you can download the .fla file from Flashkit itself - you will find the link in the left column in this page.

You can also do wonders just by changing a small part of the script. Here are just two examples. Select one from the drop down list:

» Level Intermediate

Added: 2003-04-03
Rating: 8 Votes: 46
(10 being the highest)
» Author
Living in India, going to High school. What else?
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.