So I would like to create something similar to a motion tween in flash using actionscript 3.0 code. I would like it to happen when I press a button.
The closest I get is this:
However, this shifts it without a movement. It is an instantaneous change when I would rather have it be actual movement.
Can anybody help me?
Thank you.
The easiest way for simple tweens is the built-in class. While I also advocate TweenLite/Nano/Max (greensock.com not greensocks.com) it only really matters when you're doing a large amount of tweens at a time (hundreds or thousands depending on the computer). It also helps that libraries like that let you animate multiple properties in the same line.
If you use Flash's built in code tweens you'll need to make a single new tween per property you want to animate (without getting complicated):
import fl.transitions.Tween;
import fl.transitions.easing.Regular;
// animate 4 properties on 2 objects, over 1 second
new Tween(usflag, "x", Regular.easeInOut, usflag.x, (usflag.x -= 100), 1, true);
new Tween(usflag, "y", Regular.easeInOut, usflag.y, (usflag.y -= 100), 1, true);
new Tween(russianflag, "x", Regular.easeInOut, russianflag.x, (russianflag.x -= 100), 1, true);
new Tween(russianflag, "y", Regular.easeInOut, russianflag.y, (russianflag.y += 200), 1, true);
Or if you download and load greensock.com's TweenLite SWC (or source), example:
import com.greensock.TweenLite;
import com.greensock.easing.Quad;
TweenLite.to(usflag,1,{x:(usflag.x -= 100),y:(usflag.y -= 100),ease:Quad.easeInOut});
TweenLite.to(russianflag,1,{x:(russianflag.x -= 100),y:(russianflag.y += 200),ease:Quad.easeInOut});
Both systems come with event handlers to let you know when things are complete and much more.
North America
Europe, Middle East and Africa
Asia Pacific