Robert Penner, use built-in Flash MX 2004 classes to script tweens. This is the touch of class that adds to any flash application / navigation / presentation. To set it up, you define an ease type, then apply the ease type to a Tween object.">
First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Brady White | Website:
Penner Motion Tweens Tutorial

Penner Tweens, created by Robert Penner, use built-in Flash MX 2004 classes to script tweens. This is the touch of class that adds to any flash application / navigation / presentation. To set it up, you define an ease type, then apply the ease type to a Tween object.

File -> New… -> Flash Document

Flash New Document

Double-Click ‘Layer 2′ and label it “A” (for Actions). We will place all actionscript on this layer.

Create a new layer (Insert -> Timeline -> Layer). Double-Click ‘Layer 2′ and label it “mc” (for movieclips).

Our new timeline

Draw a box using the Rectangle Tool (hotkey is ‘R’) near the top left of the Stage.

Double-Click on your new box. Now Right-Click on your box and select “Convert to Symbol…".

In the ‘Name’ field put “m_box". In the ‘Behavior’ radio button group, select “Movie clip". Press ‘OK’.

Convert symbol

Having your m_box on the stage still selected, in the ‘Properties’ toolbar, where there is a white field that has ” ” enter “box_mc". Notice that the instance name on the stage is different than the instance name on the stage. We use the “_mc” naming convention for actionscript hints in our code.

Instance name on stage

Next, select Frame ‘1′ in the ‘A’ Layer. Open up your actions panel (Window -> Development Panels -> Actions or using hotkey ‘F9′). Copy and paste this code into the ‘Actions’ panel.

var easeType = mx.transitions.easing.Regular.easeOut;
myTween = new mx.transitions.Tween(box_mc, “_y", easeType, 0, 300, 30);

Actionscript in Actions panel

Now you might be asking what this just did. Well lets take an indepth look at the code defintion of the Tween object.
(do not enter this code into your movie):

Tween(myMovie:MovieClip, myProperty:Property, easeType, startValue:Number, endValue:Number, frames(or seconds), secondsSet:Boolean);

myMovie:MovieClip – Targets the Instance of a Movieclip on the stage.
myProperty:Property – Selects the property of the Movieclip on the stage to tween. (I.E. _x, _width, _alpha, etc)
easeType as (Parent.Child) – Your tween definition set up as a variable. SetParent Types (Back, Bounce, Elastic, None, Regular, Strong). Child Types (easeIn, easeOut). (i.e. Bounce.easeOut).
startValue:Number – Starting value of property to tween. For more advanced tweens, try (box_mc._y) to get the current starting Y position of the targeted Movie Clip.
endValue:Number – Starting value of property to tween.
frames(or seconds) – Number of frames to tween over, or number of seconds to tween over.
secondsSet:Boolean – Optional value, defaults to false. When set to true, uses seconds instead of frames to tween over.

Save your document (File -> Save)

Test your movie (Control -> Test Movie or hotkey “Ctr-Enter")

Your box should go from _y position 0 to 300. Now try out variations of properties and movieclips and tweens.

For smoother framerate, try changing the framerate to 31 fps. To do so, go to Modfiy -> Document… . In the Frame rate input box, type in ‘31′. Press ‘OK’. Try your movie again.

Change Frames Per Second (FPS)

For more easing variations, view the folder on your computer >>
..Program Files/Macromedia/Flash MX 2004/en/First Run/Classes/mx/transitions

Try out Rober Penner’s examples at:
Robert Penner’s Easing Demo

Download Source Files.

» Level Basic

Added: 2004-11-16
Rating: 7 Votes: 9
(10 being the highest)
» Author
Brady White is an aspiring web developer in Utah.
» 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.