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

[Sample] BetweenAs3 Elastic

...
@author k3lab
Get Adobe Flash player
by k3lab 19 Oct 2009
    Embed
/**
 * Copyright k3lab ( http://wonderfl.net/user/k3lab )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oWwk
 */

package 
{
	import com.bit101.components.*;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import org.libspark.betweenas3.core.easing.IEasing;
	import org.libspark.betweenas3.tweens.ITween;
	import org.libspark.betweenas3.BetweenAS3;
	import org.libspark.betweenas3.easing.*;
	
	/**
	 * ...
	 * @author k3lab
	 */
	public class Main extends Sprite 
	{
		private var ball:Sprite;
		private var t:ITween;
		private var hSlider:HUISlider;
		private var aSlider:HUISlider;
		private var pSlider:HUISlider;
		
		private var radio1:RadioButton;
		private var radio2:RadioButton;
		private var radio3:RadioButton;
		private var radio4:RadioButton;
		
		private var num:int=1;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			var bg:Sprite = addChild(new Sprite()) as Sprite;
			bg.graphics.beginFill(0xFFFFFF)
			bg.graphics.drawRect(0, 0, 465, 465);
			bg.graphics.endFill();
			
			var panel:Sprite= addChild(new Sprite()) as Sprite;
			panel.graphics.beginFill(0xCCCCCC)
			panel.graphics.drawRect(0, 0, 500, 100);
			panel.graphics.endFill();
			
			var time:Label = new Label(this, 43, 20);
			time.text = "time";
			hSlider = new HUISlider(panel, 70, 20);
			hSlider.maximum = 5;
			hSlider.minimum = 0;
			hSlider.value = 1;
			
			var amplitude:Label = new Label(this, 21, 40);
			amplitude.text = "amplitude";
			aSlider = new HUISlider(panel, 70, 40);
			aSlider.maximum = 10;
			aSlider.minimum = 0;
			aSlider.value = 1.5;
			
			var period:Label = new Label(this, 35, 60);
			period.text = "period";
			pSlider = new HUISlider(panel, 70, 60);
			pSlider.maximum = 1;
			pSlider.minimum = 0;
			pSlider.value = 0;
			
			radio1 = new RadioButton(panel, 320, 15,"easeInWith",false,onChangeEasing);

			radio2 = new RadioButton(panel, 320, 35,"easeOutWith",true,onChangeEasing);

			radio3 = new RadioButton(panel, 320, 55,"easeInOutWith",false,onChangeEasing);

			radio4 = new RadioButton(panel, 320, 75,"easeOutInWith",false,onChangeEasing);

			
			ball = addChild(new Sprite()) as Sprite;
			ball.graphics.beginFill(0x0);
			ball.graphics.drawCircle(0, 0, 20);
			ball.graphics.endFill();
			ball.x = ball.y = 240;
			
			bg.addEventListener(MouseEvent.MOUSE_DOWN, _down);
			
		}
		
		private function onChangeEasing(e:Event):void {
			switch(e.target){
				case radio1:
					num = 0   
				break;
				case radio2:
					num = 1
				break;
				case radio3:
					num = 2   
				break;
				case radio4:
					num = 3
				break;    
			}
		}
		
		
		private function _down(e:MouseEvent):void {
			if (t != null) {
				t.stop();
			}
			var easing:IEasing;
			switch(num) {
				case 0:
					easing=Elastic.easeInWith(aSlider.value,pSlider.value)
				break;
				case 1:
					easing=Elastic.easeOutWith(aSlider.value,pSlider.value)
				break;
				case 2:
					easing=Elastic.easeInOutWith(aSlider.value,pSlider.value)
				break;
				case 3:
					easing=Elastic.easeOutInWith(aSlider.value,pSlider.value)
				break;
				
			}
			t = BetweenAS3.tween(ball, { x:mouseX,y:mouseY}, null, hSlider.value, easing)
			t.play();
		}
		
	}
	
}