?
Solved

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

Posted on 2009-04-20
4
Medium Priority
?
369 Views
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.
0
Comment
Question by:gpsocs
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
ugeb earned 1000 total points
ID: 24196267
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
 

Author Comment

by:gpsocs
ID: 24200286
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
 

Author Closing Comment

by:gpsocs
ID: 31572557
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
 
LVL 11

Expert Comment

by:ugeb
ID: 24200453
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

749 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