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

forked from: forked from: wonderFl_KeyVisual_v3

@author Takashi Murai(KAYAC)
Get Adobe Flash player
by ta1 08 Sep 2009
// forked from yuitamada's forked from: wonderFl_KeyVisual_v3
// forked from Murai's wonderFl_KeyVisual_v3
// forked from Murai's wonderFl_KeyVisual_v2
// write as3 code here..
package 
{
	
	/**
	 * 
	 * @author Takashi Murai(KAYAC)
	 */
	 
	import flash.display.*
	import flash.events.*
	import flash.text.*
	import flash.filters.*;
	import flash.geom.*;
	import flash.utils.*
	
	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="15")]
	
	public class WonderFL extends MovieClip
	{
		//
		var txtLayer:Sprite=new Sprite()
		var drawPos:Sprite=new Sprite()
		var textPos:Sprite=new Sprite()
		
		var txtFmt:TextFormat = new TextFormat();
		var textFields:TextField=new TextField()
		
		//message
		var messages=[
			"<_<_<_<__writecode__________",
			"_<_<_<_<_writecode__________",
			"<_<_<_<__writecode__________",
			"_<_<_<_<_writecode__________",
			"<_<_<_<__writecode__________",
			"_<_<_<_<_writecode__________",
			"<_<_<_<__writecode__________",
			"_<_<_<_<_writecode__________",
			"<_<_<_<__writecode__________",
			"_<_<_<_<_writecode__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",	
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",
			"<_<_<_<__write code__________",
			"_<_<_<_<_write code__________",	
			"and watch it move here.",
			"and watch it move here!",
			"and watch it move here.",
			"and watch it move here!",
			"and watch it move here.",
			"and watch it move here!",
			"and watch it move here.",
			"and watch it move here!",
			"it's a wonderfl world"
		]
		
		//lleasures
		var posX:Number = 30
		var posY:Number = stage.stageHeight/2
		var disX:Number = 40
		var disY:Number = 5
		var deg:Number = 0
		var count:Number = 0;  
		var step:Number =2
		var cx:Number = stage.stageWidth /2
		var cy:Number = stage.stageHeight /2
		var xPos:Number = 0
		var yPos:Number = 0
		
		//gladationLine
		var mtx:Matrix = new Matrix();
		var gradCount=1
		var gradDir=1
		var life=0
		var lifeLmt=100
		
		//fader
		var blurVall=4
		var faderAlpha=0.8
		var interval=100
		var _bdTxt:BitmapData
		var _bmpTxt:Bitmap
		var _bdLine:BitmapData
		var _bmpLine:Bitmap
		var _blurF:BlurFilter
		
		public function WonderFL() { 
			init()
			
			initFader()
			
			this.addChild(_bmpLine)
			this.addChild(_bmpTxt)
			txtLayer.addChild(textPos)
			textPos.addChild(textFields)
		}
		
		function init(){
			initLissajous()
			setMessage("","normal",0xFFFFFF)
			 faderAlpha=0.9
			
			var timerLmt=(messages.length-1)
			var phaseCnt=0
			var phase1:Timer = new Timer(interval, timerLmt);
			phase1.addEventListener(TimerEvent.TIMER, function(e:Event){
				setMessage(messages[phaseCnt++],"normal",0xFF0000)
			});
			phase1.start(); 
			
			var phase2:Timer = new Timer((timerLmt)*interval+1500, 1);
			phase2.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:Event){
				setMessage(messages[messages.length-1],"normal",0xFFFFFF)
				startLissajous()
				faderAlpha=0.999
			});
			phase2.start(); 
			
			var phase3:Timer = new Timer((timerLmt)*interval+1500+10000, 1);
			phase3.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:Event){
				reset()
			});
			phase3.start(); 
		}
		
		function reset(){
			stage.removeEventListener(Event.ENTER_FRAME, drawLissajous);  
			init()
		}
		
		function setMessage(mes:String,blend:String,hex:Number){
			txtFmt.font="Arial"
			txtFmt.align = TextFormatAlign.CENTER;
			txtFmt.color=hex
			txtFmt.size=30
			
			textFields.defaultTextFormat = txtFmt;
			textFields.multiline=true
			textFields.autoSize=TextFieldAutoSize.LEFT
			textFields.x =0
			textFields.y = 0
			textFields.text=mes
			
			
			textPos.alpha=0.5
			textPos.blendMode=blend
			
			textPos.x=stage.stageWidth/2-textFields.width/2
			textPos.y=stage.stageHeight/2-textFields.height/2
		}

		function initFader(){
			
			_bdTxt=new BitmapData(stage.stageWidth,stage.stageHeight,true,0x000000);
			_bmpTxt=new  Bitmap(_bdTxt);
			_blurF=new BlurFilter(blurVall,blurVall,3);
			
			_bdLine=new BitmapData(stage.stageWidth,stage.stageHeight,true,0x000000);
			_bmpLine=new  Bitmap(_bdLine);
			_blurF=new BlurFilter(blurVall,blurVall,3);
			
			 stage.addEventListener(Event.ENTER_FRAME, render);  
		}
		
		function render(e:Event):void {
			_bdLine.colorTransform(_bdLine.rect, new ColorTransform(1, 1, 1,faderAlpha, 0, 0, 0, 0));
			_bdLine.applyFilter(_bdLine,_bdLine.rect,new Point(0,0),_blurF);
			_bdTxt.colorTransform(_bdTxt.rect, new ColorTransform(1, 1, 1,0.9, 0, 0, 0, 0));
			_bdTxt.applyFilter(_bdTxt,_bdTxt.rect,new Point(0,0),_blurF);
			
			_bdLine.scroll(8,0)
			
			_bdLine.draw(drawPos);
			_bdTxt.draw(txtLayer);
		}
		
		function initLissajous(){
			mtx.createGradientBox(400, 400, 0, 0, 0);
			drawPos.graphics.clear()
			drawPos.graphics.lineStyle(4);  
		 	drawPos.graphics.lineGradientStyle(GradientType.LINEAR,  [0xFF0000, 0x0000FF], [1,0.2],[gradCount,255-gradCount], mtx, SpreadMethod.REFLECT);
			drawPos.graphics.moveTo(xPos,yPos);  
		}
		
		function startLissajous(){
			 stage.addEventListener(Event.ENTER_FRAME, drawLissajous);  
		}
		
		 function drawLissajous(e:Event):void {
			 count+= step;  
			 xPos = posX * Math.sin(disX * count + deg)
			 yPos = (posY) * Math.sin(disY * count) + cy
			 if(gradCount>=255 || 0>=gradCount){
				gradDir*=-1
			}
			gradCount+=gradDir
			life=life>lifeLmt?0:life+1
			if (life>lifeLmt) {
				drawPos.graphics.clear()
				drawPos.graphics.lineStyle(1);  
				drawPos.graphics.moveTo(xPos,yPos)
			}

			drawPos.graphics.lineGradientStyle(GradientType.LINEAR,  [0xFF0000, 0x0000FF], [(gradCount/255),((255-gradCount)/255)],[1,255], mtx, SpreadMethod.REFLECT);
			drawPos.graphics.lineTo(xPos,yPos);  
		}
	}
}