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

1. Simple tweens with BetweenAS3

package
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	import org.libspark.betweenas3.BetweenAS3;
	
	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(50);
			var box2:Box = addNewBox(150);
			var box3:Box = addNewBox(250);
			var box4:Box = addNewBox(350);
			
			// Parameters are:
			// .tween(Target, ToValues, FromValues, Time, Easing, Delay)
			
			// Simple Tween: from current (20) to 220
			BetweenAS3.tween(box1, {x: 220}).play();
			
			// From-To Tween: from 120 to 220
			BetweenAS3.tween(box2, {x: 220}, {x: 120}).play();
			
			// From Tween: from 220 to current (20)
			BetweenAS3.tween(box3, null, {x: 220}).play();
			
			// Relative Values (Add $ to prefix): from current + 100 (=120) to current + 200 (=220)
			BetweenAS3.tween(box4, {$x: 200}, {$x: 100}).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();
	}
}