• home
  • forum
  • my
  • kt
  • download
  • Movie Clip Follower

    Author: 2009-07-14 07:41:35 From:

    This tutorial will teach you how to create a cool animated mouse follower. It’s very easy to change to looks of the follower to fit for your needs!

    Note: You need TweenMax in order to complete this tutorial

    Creating the Document

    First, create a new Flash ActionScript 3 document.

    Create a Flash ActionScript 3 Document

    Document Settings

    Set the stage options to the following.

    Flash Document Properties

    Creating the Background

    With the rectangle tool, create a 400×300 sized rectangle without any stroke. Align it to the center of the stage.

    Flash Align

    Add a radial fill for the rectangle (left color: #00CCFF, right color: #000000)

    Flash Radial Fill

    New Layer for the Follower Movie Clip

    Create a new layer named “follower”.

    Flash New Layer

    Create the Follower Movie Clip

    In the “follower” layer, draw a white cirle without any stroke. Make it size 25×25. Convert the circle to a movie clip with the following settings.

    Flash Convert to Movie Clip

    Instance Name

    Give the follower movie clip an instance name of “follower”.

    Instance Name

    Time for the ActionScript 3

    Now that we have everything set up on the stage, let’s add some ActionScript to actually make the follower to follow our cursor! Create a new layer called “actions” and type the following.

    //Import TweenMax
    import gs.*;
     
    //Listen when the mouse moves
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoves);
     
    //This function is called when the mouse moves
    function mouseMoves(e:Event):void {
     
    	//Tween the follower movie clip to the cursor's coordinates
    	TweenMax.to(follower, 0.5 ,{x :mouseX, y: mouseY});
    }

    Here we just listen when the mouse moves and when it does, we tween the follower to the cursor’s coordinates. We use TweenMax to make our lives a little easier ;) To add the blurry animation for our mouse follower, type the following code.

    //Call the function which tween various properties of the follower
    up();
     
    //This function adds more blur and scales the follower
    function up():void {
     
    	//Tween the blur
    	TweenMax.to(follower, 0.5, {blurFilter:{blurX:15, blurY:15}});
     
    	//Tween the scale and call the function down() when finished
    	TweenMax.to(follower, 0.5, {scaleX: 1.5, scaleY:1.5, onComplete: down});
    }
     
    //This function removes blur and scales the follower
    function down():void {
     
    	//Tween the blur
    	TweenMax.to(follower, 0.5, {blurFilter:{blurX:10, blurY:10}});
     
    	//Tween the scale and call the function up() when finished
    	TweenMax.to(follower, 0.5, {scaleX: 0.5, scaleY:0.5, onComplete: up});
     
    }

    As you can see, all the animation is done in the down() and up() functions. We simply go back and forth between the functions…

    Final Words

    That’s the end of this tutorial. I hope you enjoyed it and find it useful. Check out the .fla file if you’re still wondering how this works. And you have any questions or trouble, pls post them in the new forum!

    Download .fla

    discuss this topic to forum

    relation tutorial

    No information

    Category

      3D (36)
      Math Physics (18)
      3rd Party (10)
      Navigation (70)
      Actionscripting (244)
      Optimization (17)
      Animation (185)
      Projector (11)
      Audio (54)
      Special Effects (173)
      Backend (26)
      Text Effects (93)
      Drawing (34)
      Tips and Techniques (58)
      Dynamic Content (38)
      Tricks (8)
      Games (114)
      Utilities (24)
      Getting Started (99)
      Video (59)
      Interactivity (48)
      Web Design (37)

    New

    Hot