Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 


Mouse Follow with Easing
         by Shane Waldeck (aka lostinbeta)

Introduction
Easing is an important part of Actionscripted(AS) motion. It adds a realistic feel by speeding up and slowing down an object depending on its position to its final destination. This tutorial will teach you the basics of easing by moving an object to where the mouse is (aka mouse trailing/following). This is probably the simplest form of easing. You can download the partial .fla file HERE, the partial .fla file does not contain any actions or key elements that make the effect work.
 

[ move mouse on movie above to see example ]

Steps to Create Animation
The following steps will help you to create the animation you see above:

  1. The first step is to create a new movie any size you would like.
     
  2. The next step in creating this is by drawing a ball (for sake of simplicity) on the main stage.
     
  3. Next up we want to make this ball a movie clip. Press F8 on your keyboard then choose "Movie Clip" from the list of radio buttons. Name this movie clip "ball" (naturally).
     
  4. Ok, all we have to do now is add actions to the ball to make this puppy follow the mouse. Just remember this isn't your typical mouse follower, this uses easing to make it more realistic and flowing. To open the "Actions" window, right click on your movie clip and click on "Actions".
     
  5. Apply these actions to your movie clip...

  1. Now test your movie (CTRL+Enter) ... much more realistic than your typical follower don't you think?
     
  2. You can download my final .fla file HERE.

Explanation of Code:

The first thing to explain is of course what goes on in the onClipEvent(load).  


What this does is moves your movie clip to the "x" and "y" coordinate of (0,0), this is the upper left hand corner. It also sets the speed of the effect to "5". To edit the speed, keep in mind that the higher the number, the slower the transition and the lower the number, the faster the transition.

The onClipEvent(enterFrame) is what makes the whole thing happen.  


This sets the end target as the same (x, y) location as your mouse. Then it subtracts the current (x, y) location from the new one and divides it by the speed. Dividing it by the speed with slow down the time it takes to get to its destination. This will loop around and around until it finally reaches it's final destination......your mouse.
 

-Shane Waldeck (aka lostinbeta)
-www.lostinbeta.com-

 


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Buy and sell FLAs at Ultrashock! Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Purchase & Download Flash Components flash components
Learn how to advertise on kirupa.com