[AS3]Using caurina Tweener

Tecsi Aron
Been working in IT since 2000, mostly in VB* till 2 years ago, when i migrated to Flash and AS3. Made several projects that combine AS3 with PHP. Mostly worked on games and Desktop applications.
View all articles by Tecsi Aron- The native one has bugs. For example if you are simultaneously tweening 3 objects with native Tween class, from time to time you notice that one or more Tweens simply stop (at least this happened to me a lot while I was using the native class).
- You need 1 tween / tweened property. (If you move an object both on x and y you need two Tweens)
- It uses the same event model as everything in AS3(This is not necessarily bad, bit with Caurina Tweener you can not only specify the name of the handling function, you can also specify its parameters)
- Works fine regardless of the Tweened objects.
- Gives better performance.
- You can tween multiple properties of 1 object with a single line of code
- It's built with static functions, meaning that you don't need an instance of the class every time you want to make a tween.
The black box having instance name "box", and the initial alpha being 0.5 the code is:
import caurina.transitions.Tweener;
Tweener.addTween(box,{x:300, y:100, alpha:1, time:2, transition:"linear"});
Animation sequences are also much easer to make, as you no longer need to synchronize your tweens using events, for example:
There are practically two tweens one that changes x,y and alpha, it lasts 2 seconds as you can see in the code above, and one that changes the rotation.
The code is:
import caurina.transitions.Tweener;
Tweener.addTween(box,{x:300, y:100, alpha:1, time:2, transition:"linear"});
Tweener.addTween(box,{rotation:50, time:1, transition:"linear",delay:2.5});
No events no nothing just one extra parameter: "delay". As you can see it's set to 2.5, the length of the first tween is 2, so practicly the second tween starts 0.5 seconds after the first one finishes.
Still you may want to do something when your tween finishes playing, you accomplished this by 'addEventListener(Event.COMPLETE)' with tweener it's just another parameter as such:
Tweener.addTween(box,{rotation:50, time:1, transition:"linear",delay:2.5, onComplete:doThis});
function doThis()
{
trace("here");
}
doThis will be called when tween has completed. As you can see doThis doesn't have any parameters, wich might be good, but in case you do need parameters, that is easy to acomplish as well:
Tweener.addTween(box,{rotation:50, time:1, transition:"linear",delay:2.5, onComplete:doThis, onCompleteParams:["hello world"]});
function doThis(s:String)
{
trace(s);
}
NOTE: "hello world" can be replaced with a variable, or with multiple variables separated with comas. For example:
var nr1:Number=1;
var nr2:Number=2;
var nr3:Number=3;
Tweener.addTween(box,{rotation:50, time:1,
transition:"linear",delay:2.5, onComplete:doThis,
onCompleteParams:[nr1,nr2,nr3]});
function doThis(n1:Number, n2:Number, n3:Number)
{
trace(n1+n2+n3);
}
You can download examples from here.
You can read the online documentation for Tweener here.
You can download Tweener from here.
Hope somebody will find this usefull,
Best regards.
Spread The Word
Attachments
12 Responses to "[AS3]Using caurina Tweener" 
|
said this on 11 Jul 2009 6:42:30 AM CST
What a cool tutorial! Thi
|
|
said this on 28 Aug 2009 4:04:35 PM CST
Use easeoutExpo in the tr
|
|
said this on 17 Jul 2009 10:32:21 AM CST
Hi this is good. I wonder
|
|
said this on 19 Jul 2009 6:39:10 PM CST
Object you're tweening:
You can also p Then th Parameters like the x po var obj:Object = obj["x"] = 100; ob obj.time = obj.transition = "li obj.onComplete = Tweener.addTw |
|
said this on 17 Jul 2009 11:32:33 PM CST
This actually taught me s
I didn |
|
said this on 20 Jul 2009 3:46:05 AM CST
Since I used tweener for
|
|
said this on 29 Jul 2009 2:28:47 PM CST
"The native one has bugs.
Third-party tween |
|
said this on 29 Jul 2009 3:34:35 PM CST
nice beginner stuff.
and |
|
said this on 30 Jul 2009 3:55:21 PM CST
Nicely covered, I'm the s
Things like fra You can It It allows you to mo It has ac Cau http://blo incase it |
|
said this on 17 Sep 2009 1:23:50 PM CST
To Dave: I guess you have
- AS2 - Use a fram - Tweens stay i - onCom - Modify/overwrite ac - All filters s - Delay. H Here's so |


Author/Admin)