First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
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;
    	}
    	iFireCount++;
    	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);
    	}
    }
    Mouse.hide();
    
    Explanation:
    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:
    MouseTrails();
    In the last frame alone, include this extra line:
    gotoAndPlay(2);
    Tip:
    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.

Note:
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!

Comments

  • 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: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.