Skip navigation

This is an example of tween animation, there are many reasons you may want to animate with script rather than the timeline, personally I prefer to use script where possible so that if I should later want to change the animation it requires a lot less effort than editing a timeline. This can be especially painful if you have many animations on the same timeline for example.

Here is some super simple sample code that simply fades a movie clip with an instance name of ‘mcBlock’ over a period of two seconds when you click on a movie clip with the instance name of ‘mcFadeButton’.

———– code sample

import fl.transitions.Tween;
import fl.transitions.easing.*;

var myTween:Tween;

function handleMouseUp(e:MouseEvent):void
        myTween = new Tween(mcBlock, “alpha”,None.easeNone,1,0,2,true);

mcFadeButton.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);

———– end code sample

I will save explaining the various parameters of the Tween to the help file in Flash. But briefly what I have going on here is this…

myTween = new Tween(instance name on the stage, “text string of the property to animate“,easing class,starting value,ending value,time in seconds,boolean to say seconds rather than milliseconds);

I have also uploaded a zip file containing an example fla and swf files here.


    • ben peter
    • Posted July 23, 2008 at 5:46 am
    • Permalink

    i’ve work in maya and max for over 6 years, but i’m a newb to action scripting. i’ve been trying to develope a website for my work. trying to figure out how to make several buttons that are each directed to different movie clips fade in and out to the specific movie clip, but the last movie clip must fade out no matter which button the user picks? any help here? i would really appreciate it.

  1. The explanation at the end where you say

    “,boolean to say seconds rather than milliseconds);”

    is wrong.

    it should be :

    Indicates whether the tween plays over a period of frames or seconds.


    • treehuggergraeme
    • Posted February 22, 2010 at 12:39 pm
    • Permalink

    finally someone who converts all this flash code into real language, thanks for the excellent explanation – i’ve been searching for a while and this example is exactly what I was looking for – sample file is great.

    thanks again

    • Pedro
    • Posted March 2, 2010 at 7:59 am
    • Permalink

    Thank you for this short but big code!!!

    • Php Coder
    • Posted June 27, 2010 at 8:58 am
    • Permalink

    It is really helpful code. Thanks

  2. nice snippet, thank you for sharing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: