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

モザイクカメラ

Wonderflしてるみんなへ!
 flash.media.Cameraで遊んでると
うっかり無防備な自分の顔がサムネイルされちゃうぞ!やってみよう!
//
// Wonderflしてるみんなへ!
// flash.media.Cameraで遊んでると
// うっかり無防備な自分の顔がサムネイルされちゃうぞ!やってみよう!
//
// forked from minon's どっとかめら
// forked from minon's webcam

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.Camera;
	import flash.media.Video;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.utils.getTimer;
	

	[SWF(width = 360, height = 240, backgroundColor = 0x000000, frameRate = 30)]

	/*********************************************
	 *
	 * モザイクカメラ
      	 * 
	 *******************************************/
	public class Main extends Sprite{
		
		private var view:Sprite;
		private var camera:Camera;
		private var video:Video;
		private var screen:Sprite;
		
		private var dotSize:Number;
		
		
		//======================================
		// コンストラクタ
		//======================================
		public function Main():void{
			
			init();
		}
		
		private function init():void{
			
			screen = addChild( new Sprite() ) as Sprite;
			view = addChild( new Sprite() ) as Sprite;
			
			camera = Camera.getCamera();
			camera.setMode( 400, 300, 30 );
			video = new Video( 400 , 300 );
			video.attachCamera( camera );
			
			///プレビュー
			addChild(video)
			video.width = 120;
			video.height = 90;
			//*/
			
			addEventListener(Event.ENTER_FRAME, _render);
		}
		
		
		private function _render(e:Event):void {
			
			dotSize = Math.sin(getTimer()/1000)*10 + 15;
			var _bmd:BitmapData = new BitmapData(400, 300);
			_bmd.draw(video);
			
			
			screen.graphics.clear();
                        for (var i:int = 0; i < 400 / dotSize ; i++) {
                            for (var j:int = 0; j < 300 / dotSize ; j++) {

                                var col:int = _bmd.getPixel( i*dotSize, j*dotSize );
                                screen.graphics.beginFill( col );
                                screen.graphics.drawRect(i*dotSize, j*dotSize, dotSize, dotSize );
                                screen.graphics.endFill(); 
                            }
                        }
			
		}
		
		
		
	}
}