This page require Adobe Flash 9.0 (or higher) plug in.

ActionScript 3.0 : Using Tweener Class

I just came across these Tweener Class while browsing through Google just today – find it quite interesting for those interested in building interactive applications using AS3.

Firstly it is lightweight and does not need to code much to get movement animation you desire e.g. rotation, linear tween and stuff you do in the normal tweening in Flash. You can actually use this class, to build some lightweight interactive menu stuff project.

Check out the sample SWF I Attached Here. A cute image movieClip called CuteMC is used for this demonstration and also a status dynamic text container in the stage. Hah..ha Check out my summersault doggy.

 


All you need to do is to download the AS3 version of the actionscript file and unzip the folder caurina to your same swf of your project.

Below are my source code sample used to do some simple tweening as shown above.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package{
	import flash.display.*;
	import flash.events.*;
	import caurina.transitions.*
	import flash.text.*;
 
	public class tweener extends MovieClip {
		public function tweener()
		{
			var MyCuteMC = new CuteMC();
			MyCuteMC.x = 100;
			MyCuteMC.y = 100;
			addChild(MyCuteMC);
			MyCuteMC.addEventListener(MouseEvent.MOUSE_OVER,doTween);
			MyCuteMC.buttonMode = enabled;
		}
 
		private function doTween(event:Event):void{
			if(event.target.x != 250){
				Tweener.addTween(event.target, {x:250,alpha:1, rotation:360, time:0.3, transition:"linear", onComplete:doMsg});
			}else{
				Tweener.addTween(event.target, {x:100,alpha:1, rotation:-360, time:0.3, transition:"linear", onComplete:doMsg});
			}
		}
 
		private function doMsg():void{
			Status.text = "Tween Sequence Complete, Mouse Over on It Again";
		}
	}
}

As you notice there’s even a handy onComplete function inside the function. This allows you to do chaining sequence of animation one after another or simply just fire some event like what I did. I fired an event which triggers a status.text changes.
Here is my full source for your checking here.

Other Cool Related Stuff

1 Comment so far »

  1. Is Good Stuff » ActionScript 3.0: Tweener Class Adobe Class fl.transitions.* said

    am September 22 2008 @ 2:20 pm

    [...] Hmmm, interesting. I was playing around with Adobe tweening classes just last week. These tweening classes are the default ones found in CS3 (Note this is not the open source ones, as listed in this post here) [...]

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment:

CommentLuv Enabled