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

pixel benderでブラー

Get Adobe Flash player
by keno42 06 Mar 2009
package  
{
	import flash.display.*;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.filters.*;
	import flash.net.*;
	import flash.system.Security;
	import flash.text.*;
	
	public class Moji extends Sprite
	{
		private var loader:URLLoader;
		private var filter:ShaderFilter;
		private var sprite:Sprite = new Sprite();
		private var back:Shape = new Shape();
		private var backBmp:BitmapData = new BitmapData(400, 400, true, 0xFF000000);
		private var theta:Number = 0.0;
		
		public function Moji() 
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP;
			loader = new URLLoader();
			loader.dataFormat = URLLoaderDataFormat.BINARY;
			loader.addEventListener(Event.COMPLETE, onComp);
			loader.load( new URLRequest("http://www.nyafuri.com/flash/blur.pbj"));
			this.x = 0;
			this.y = 0;
		}
		private function onComp(event:Event):void {
			var shader:Shader = new Shader((event.currentTarget as URLLoader).data);
			shader.data.c.value = [3.0];
			shader.data.backImage.input = backBmp;
			stage.addEventListener(Event.ENTER_FRAME, onEnter);
			this.addChild( sprite );
			this.graphics.beginFill(0xFFFFFF, 0);
			this.graphics.drawRect(0, 0, 400, 400);
			var textfield:TextField = new TextField();
			textfield.defaultTextFormat = new TextFormat("_sans", 30);
			textfield.autoSize = TextFieldAutoSize.LEFT;
			textfield.text = "TEST TEST TEST";
			textfield.y = -20;
			sprite.addChild( textfield );
			sprite.graphics.beginFill(0x0,0.4);
			sprite.graphics.drawRect( 0, -20, 260, 40);
			sprite.x = 200;
			sprite.y = 200;
			filter = new ShaderFilter(shader);
		}
		private function onEnter(event:Event):void {
			theta += 0.015625;
			sprite.rotationY = theta * 180 / Math.PI;
			var matrix:Matrix = new Matrix();
			var scaleVar:Number = sprite.width *0.0006;
			matrix.scale(scaleVar,1);
			matrix.translate(200 - scaleVar * 800,0);
                        back.graphics.clear();
			back.graphics.beginGradientFill(
				GradientType.LINEAR,
				[0x10000 * Math.floor(Math.abs(255*Math.sin(theta))), 0x0],
				[1, 1], 
				[0, 255], 
				matrix, 
				SpreadMethod.REFLECT
			);
			back.graphics.drawRect(0, 0, 400, 400);
			backBmp.draw( back );
			this.filters = [filter];
		}
	}
}