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

いっこく堂カメラ

from zk_diary 2007-08-20 http://d.hatena.ne.jp/zk3/20070820
Get Adobe Flash player
by sakotsu 24 May 2009
/**
 * Copyright sakotsu ( http://wonderfl.net/user/sakotsu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xI4i
 */

// forked from Saqoosha's Sakotsu Camera
// from zk_diary 2007-08-20 http://d.hatena.ne.jp/zk3/20070820

package {
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.media.Camera;
	import flash.media.Video;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	
        [SWF(width=500, height=240, frameRate=30)]
	
	public class Main2 extends Sprite{
		
		private var camera:Camera;
		private var video:Video;
		private var screen:Bitmap;
		
		private static const BUFFER_LEN:int = 16;
		private var bufferList:Array = [];
		private var bufferIndex:int = 0;
		
		
		//=================================================
		// コンストラクタ
		//=================================================
		public function Main2():void{
			
			init();
		}
		
		private function init():void{
			
			camera = Camera.getCamera();
			camera.setMode( 250, 240, 30 );
			video = new Video( 250 , 240 );
			video.attachCamera( camera );
			addChild(video);
			
			for (var i:int = 0; i < BUFFER_LEN; i++) {
				var bm:BitmapData = new BitmapData(400, 300, true, 0x00ffffff);
				bufferList.push(bm);
			}
			
			screen = addChild( new Bitmap() ) as Bitmap;
			screen.scaleX = -1;
			screen.x = 500;	
			
			var tf:TextField = addChild( new TextField() ) as TextField;
			tf.text = "声が 遅れて 聞こえて くるらしい";
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.x = stage.stageWidth / 2 - tf.width / 2;
			tf.y = 10;

			
			
			addEventListener(Event.ENTER_FRAME, render);
		}
		
		
		// ■描画
		//----------------------------------------------------------------
		private function render(e:Event):void {
			
			BitmapData(bufferList[bufferIndex]).draw(video);
			
			if ( ++bufferIndex == BUFFER_LEN){
				bufferIndex = 0;
			}
			
			screen.bitmapData = bufferList[ bufferIndex ];
			
		}
		
		
		
		
		
		
		
	}
}