Reputation: 12847
I've created a simple shape(MovieClip) in main Scene.
So, i wanna move that shape via Motion Tween
in ActionScript.
Please tell me how can i do that ?
Notice :
I'm not talking about create Motion Tween
in flash timeline. I need to do that in ActionScript.
P.S :
I'm using Flash Professional.
Upvotes: 1
Views: 10642
Reputation: 3141
As much as Tween class can help you, I strongly encourage you not to use it. Mainly for the performance reason.
To tween effectively, easy and fast I recommend you to use a free open-source tweener called TweenLite: http://www.greensock.com/tweenlite/
It is a very advanced tool, there are many examples and tutorials on how to use it, but it can all come down to a small line like this one:
TweenLite.to(yourObject, duration, {x: EndX, y: EndY});
Upvotes: 3
Reputation: 6230
Example code from official reference.
import fl.transitions.Tween;
import fl.transitions.easing.*;
var myTween:Tween = new Tween(myObject, "x", Elastic.easeOut, 0, 300, 3, true);
Also here is a tutorial to the topic.
Just for your info: you can tween not only position of the object but also other numeric parameters, e.g. width and height.
Upvotes: 2
Reputation: 191
If you want to move your object on the X and Y axes, you will need two tweens. Here is the code in ActionScript 3:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var tweenX:Tween = new Tween(nameOfYourObject, "x", Strong.easeIn, startPositionX, endPositionX, numberOfSeconds, true);
var tweenY:Tween = new Tween(nameOfYourObject, "y", Strong.easeIn, startPositionY, endPositionY, numberOfSeconds, true);
Make sure to define the starting and ending positions for both x and y and the number of seconds you want the tween to last.
Upvotes: 1