In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

3. Tween processing with BetweenAS3

Get Adobe Flash player
by beinteractive 08 May 2009
package
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	import org.libspark.betweenas3.BetweenAS3;
	import org.libspark.betweenas3.tweens.ITween;
	import org.libspark.betweenas3.easing.*;
	
	public class Sample extends Sprite
	{
		public function Sample()
		{
			(addChild(new TextField()) as TextField).text = 'Click to start';
			stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
		}
		
		private function mouseUpHandler(e:MouseEvent):void
		{
			while (numChildren > 0) {
				removeChildAt(0);
			}
			
			var box1:Box = addNewBox(40);
			var box2:Box = addNewBox(140);
			var box3:Box = addNewBox(240);
			var box4:Box = addNewBox(340);
			var box5:Box = addNewBox(440);
			
			// Base tweens
			var t1:ITween = BetweenAS3.tween(box1, {x: 220}, null, 1.2, Bounce.easeOut);
			var t2:ITween = BetweenAS3.tween(box2, {x: 220}, null, 1.2, Bounce.easeOut);
			var t3:ITween = BetweenAS3.tween(box3, {x: 220}, null, 1.2, Bounce.easeOut);
			var t4:ITween = BetweenAS3.tween(box4, {x: 220}, null, 1.2, Bounce.easeOut);
			var t5:ITween = BetweenAS3.tween(box5, {x: 220}, null, 1.2, Bounce.easeOut);
			
			// Reversed Tween
			BetweenAS3.reverse(t1).play();
			
			// Scaled Tween
			BetweenAS3.scale(t2, 2.0).play();
			
			// Sliced Tween
			BetweenAS3.slice(t3, 0.4, 0.8).play();
			
			// Repeated Tween
			BetweenAS3.repeat(t4, 3).play();
			
			// Sliced Scaled Reversed Repeated Tween
			BetweenAS3.repeat(
				BetweenAS3.reverse(
					BetweenAS3.scale(
						BetweenAS3.slice(t5, 0.4, 0.8),
						3.0
					)
				), 3
			).play();
		}
		
		private function addNewBox(y:Number):Box
		{
			var box:Box = new Box();
			box.x = 20;
			box.y = y;
			addChild(box);
			return box;
		}
	}
}

import flash.display.Sprite;

internal class Box extends Sprite
{
	public function Box()
	{
		graphics.beginFill(0);
		graphics.drawRect(-10, -10, 20, 20);
		graphics.endFill();
	}
}