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

ppworks logo 作成中

Get Adobe Flash player
by naoto5959 31 Dec 2008
    Embed
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.Timer;
	
        [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="15")]  

	public class Main extends MovieClip
	{
		// _____________________________________________________ Property
		/** words of logo */		
		public static const LOGO_WORDS:String = "ppworks is ... piyo piyo works !!         ";
		/** rotation radius */
		public static const ROTATION_RADIUS:Number = 500;
		
		/** rotation center z(depth) */
		public static const ROTATION_CENTER_Z:Number = 950;
		
		/** screen z(depth) */
		public static const SCREEN_Z:Number = 400;
		
		/** words TextField list */
		private var _words:Array;
		
		/** base object */
		private var _base:Sprite;
		
		/** rotation */
		private var _rotation:Number = 0;
		
		// _____________________________________________________ Method
		/**
		 * constructor
		 */
		public function Main() 
		{
			// create base which center is screen center
			_base = new Sprite();
			_base.x = stage.stageWidth / 2;
			_base.y = stage.stageHeight / 2;
			addChild(_base);
			
			// push logo words
			_words = [];
			for (var i:uint = 0; i < Main.LOGO_WORDS.length; i++)
			{
				var txt:TextField = new TextField();
				txt.defaultTextFormat = new TextFormat("Arial", 48, 0xffffff, true);
				txt.text = LOGO_WORDS.charAt(i);
				var bitmapData:BitmapData = new BitmapData(txt.textWidth, txt.textHeight, true, 0x00000000);
				bitmapData.draw(txt,null,null);
				var bitmap:Bitmap = new Bitmap(bitmapData);
				var angleX:Number = (-Math.PI/2) + ((i / Main.LOGO_WORDS.length) * Math.PI * 2);
				
				var x:Number = Main.ROTATION_RADIUS * Math.cos(angleX);
				var y:Number = 0;
				var z:Number = Main.ROTATION_CENTER_Z + Main.ROTATION_RADIUS * Math.sin(angleX);
				
				bitmap.x = x * Main.SCREEN_Z / z;
				bitmap.y = y * Main.SCREEN_Z / z;
				
				bitmap.scaleX = Main.SCREEN_Z / z;
				bitmap.scaleY = Main.SCREEN_Z / z;
				
				_base.addChild(bitmap);
				_words.push({target:bitmap, x:x, y:y,z:z});
			}
			
			var timer:Timer = new Timer(33, 0);
			timer.addEventListener(TimerEvent.TIMER, timerListener);
			timer.start();
		}
		
		/**
		 * timer event listener
		 * @param	event
		 */
		private function timerListener(event:TimerEvent):void
		{
			for (var i:uint = 0; i < _words.length; i++)
			{
				var angleX:Number = _rotation + (-Math.PI/2) + ( (i / _words.length) * Math.PI * 2);
				var targetX:Number = Main.ROTATION_RADIUS * Math.cos(angleX);
				var targetZ:Number = Main.ROTATION_CENTER_Z + Main.ROTATION_RADIUS * Math.sin(angleX);
				
				var bitmap:Bitmap = _words[i].target;
								
				_words[i].x = targetX;
				_words[i].z = targetZ;
				
				bitmap.x = _words[i].x * Main.SCREEN_Z / _words[i].z;
				bitmap.y = _words[i].y;			
				
				bitmap.scaleX = Main.SCREEN_Z / _words[i].z;
				bitmap.scaleY = Main.SCREEN_Z / _words[i].z;
				bitmap.alpha = Main.SCREEN_Z / _words[i].z;
				
				
			}
			_rotation += -5 *Math.PI/2 / 360;
		}
		
	}
	
}