What's the best way to do AS3 driven animation in Flash CS4?

Posted on 2009-04-20
Last Modified: 2013-11-11
I have an array of sprites that I want to scroll across the screen at a constant pace with some padding between them. This is a very simple animation, and I was wondering if there was some stuff in AS3 that made this particularly easy to do.
Question by:gpsocs
    LVL 11

    Accepted Solution


    You need to use a Tween which will take an object and interpolate that object's property or properties between start and ending points.  You can tween the x and y locations, rotation, alpha property, and a number of others.

    Here's a link to the Adobe docs:

    All you do is instantiate the tween:

    var tw:Tween = new Tween(obj, prop, func, begin, finish, duration);

    which follows this structure:
    Tween(obj:Object, prop:String, func:Function, begin:Number, finish:Number, duration:Number, useSeconds:Boolean = false)

    Here's an example of a tween:

    make sure your object has an instance name if you created it in the authoring tool, as that is the object you will use as the first argument of the Tween.


    Author Comment

    Thank you for the information. I have multiple images that need to be tweened across the screen in sequence. Since the images may vary in width, I am not sure if this solution will work. I did not say this in my original question, however, so I will still give you full points.

    Author Closing Comment

    This solution will not work for me for reasons that I did not include in the original question. I did not think those details were necessary at the time. I will still reward you full points for answering my question.
    LVL 11

    Expert Comment

    I'm not sure why you think this wouldn't work for you.  Each image can be tweened separately, and in sequence.

    Personally I user Tweener for all my tweens.  It's a 3rd party, free tweening class that's more powerful, easier to user, and, remarkably, even more reliable than the built in Tween class.

    With Tweener, you can even set a delay before the tween starts, so you would be able to set up a sequence of tweens all in one spot in your code.

    I'm not sure why the width difference would make a difference, but check out Tweener and you'll see how convenient and powerful it is.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now