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

TweenerでHello World!!

Get Adobe Flash player
by siba2260 15 Feb 2009
package
{
	import caurina.transitions.Tweener;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	[SWF(width=800, height=600, backgroundColor=0xAADDFF)]

	public class Main02 extends Sprite
	{
		// ----------------------------
		//	メンバ変数
		// ----------------------------
		
		private var textFields:Array = [];
		private var textFieldPoints:Array = [];
		private var isReset:Boolean = true;
		
		
		// ----------------------------
		//	初期化
		// ----------------------------
		
		public function Main02()
		{
			var word:String = "Hello World!!";
			cutWord(word);
			
			stage.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		
		// ----------------------------
		//	内部メソッド
		// ----------------------------
		
		private function cutWord(word:String):void
		{
			for (var i:int=0; i<word.length; i++)
			{
				var character:String = word.charAt(i);
				var textField:TextField = new TextField();
				textField.defaultTextFormat = new TextFormat(null, 50);
				textField.text = character;
				addChild(textField);
				textField.x = stage.stageWidth/2 - 200 + i*40;
				textField.y = stage.stageHeight/2;
				textFields.push(textField);
				textFieldPoints.push({x:textField.x, y:textField.y});
				Tweener.addTween(textField, {x:Math.random()*stage.stageWidth, y:Math.random()*stage.stageHeight, time:1, transition:"easeOutBack"});
			}
		}
		
		
		// ----------------------------
		//	イベント
		// ----------------------------
		
		private function onClick(event:MouseEvent):void
		{
			for each (var word:TextField in textFields)
			{
				if (isReset)
				{
					var point:Object = textFieldPoints[textFields.indexOf(word)];
					Tweener.addTween(word, {x:point.x, y:point.y, time:1, transition:"easeOutBack"});
				}
				else
				{
					Tweener.addTween(word, {x:Math.random()*stage.stageWidth, y:Math.random()*stage.stageHeight, time:1, transition:"easeOutBack"});
				}
			}
			isReset = !isReset;
		}
		
	}
}