• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

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

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.
0
gpsocs
Asked:
gpsocs
  • 2
  • 2
1 Solution
 
ugebCommented:
Yes,

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:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/transitions/Tween.html

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:

http://www.zedia.net/actionscript-3-tweens-tutorial/


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.


0
 
gpsocsAuthor Commented:
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.
0
 
gpsocsAuthor Commented:
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.
0
 
ugebCommented:
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.

http://code.google.com/p/tweener/

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.

HTH
Gene



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now