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

MotionBlur風Camera

重い・・・
Get Adobe Flash player
by 178ep3 04 Dec 2009
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lbFV
 */

//重い・・・
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.media.Camera;
	import flash.media.Video;
	
	import net.hires.debug.Stats;
	
	public class MotionBlurCamera extends Sprite
	{
		private var _bmdList:Vector.<BitmapData> = new Vector.<BitmapData>();
		private var _bmd:BitmapData;
		private var _bmp:Bitmap;
		private var _camera:Camera;
		private var _video:Video;
		
		public function MotionBlurCamera()
		{
			if(!stage)addEventListener(Event.ADDED_TO_STAGE,init);
			else init();
		}
		
		private function init(e:Event=null)
		{
			_camera = Camera.getCamera();
			_camera.setMode(465,465,30);
			_video = new Video(465,465);
			_video.attachCamera(_camera);
			_bmd = new BitmapData(465,465,true,0);
			_bmp = addChild(new Bitmap(_bmd))as Bitmap;
			addChild(new Stats());
			
			addEventListener(Event.ENTER_FRAME,loop);
		}
		
		private function loop(e:Event):void
		{
			var bmd:BitmapData = new BitmapData(465,465,true,0);
			bmd.draw(_video);
			_bmdList.unshift(bmd);
			if(_bmdList.length>30)_bmdList.pop();
			
			var i:int = 0;
			var len:uint = _bmdList.length;
			for(i=0; i<len; i++)
			{
				_bmd.draw(_bmdList[i],null,new ColorTransform(1,1,1,(30-i)/30));
			}
		}
	}
}