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

monokurocamera

import flash.geom.Rectangle;
import flash.geom.Matrix;
Get Adobe Flash player
by crea 14 Jan 2009
package {
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.display.PixelSnapping;
	import flash.events.MouseEvent;
	
	import flash.display.Sprite;
	
	import flash.display.BitmapDataChannel;
	
	//import flash.geom.Rectangle;
	//import flash.geom.Matrix;
	import flash.geom.*;
	
	import flash.utils.ByteArray;

	import flash.media.Camera;
	import flash.media.Video;
	import flash.events.ActivityEvent;
	import flash.events.*;
	
	public class bitmap7 extends Sprite {
		/*クラスファイル*/
		
		var sp:Sprite=new Sprite();
		var pnt:Point=new Point(0,0);
		
		
		
		//camera
		var camera:Camera; 
		
		var video:Video;
		var photo_bm:Bitmap;
		var photo_bd:BitmapData;
		
		var sa_bm:Bitmap;
		var sa_bd:BitmapData;
		
		
		var photo_bdfront:BitmapData;
		var photo_bdback:BitmapData;
		var enterflag:int=0;
		var shot1fla:int=0;
		
		//var bmd:BitmapData=new BitmapData(200,120,false,0xFFFFCC00);
		//幅(ピクセル数1~2880),高さ(ピクセル数1~2880),アルファチャンネルをtrueサポート false非サポート
		//0xFFFFFFFF白
		//var bm:Bitmap=new Bitmap();daichi
		
			
		

		
		public function bitmap7() {

			sp.addEventListener(MouseEvent.CLICK,enterFramebtn);				
			
			
			
			//camera
			// カメラソースを取得
			 camera = Camera.getCamera();
		//ボタンの設定
			 // 表示処理
			initCamera();
			initPhoto();
			

			sp.addChild(video);
			addChild(sp);
			

			}
			
			
			function enterFramebtn(evt:Event):void{
				if(enterflag==1){
					removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
					enterflag=0;
					shot1fla=0;
					
				}else if(enterflag==0){
				addEventListener(Event.ENTER_FRAME,enterFrameHandler);
				enterflag=1;
				
				}
			}
			
			function enterFrameHandler(evt:Event):void{
				
				
				
				
				
				var thrCol1:uint=0x00777777;
				var col1:uint=0xFF0000FF;
				var mskCol1:uint=0x000000FF;
				//bm.bitmapData.threshold(nextBmd,nextBmd.rect,pnt,"<",thrCol,col,mskCol,true);
				//過去青 未来赤
				
				
				if(shot1fla==0){
				sa_bm.bitmapData.draw(video);
				
				sa_bm.bitmapData=threshold_filter(sa_bm.bitmapData);
				//photo_bm.bitmapData.threshold(photo_bd,photo_bd.rect,pnt,"<",thrCol,col,mskCol,true);
				//photo_bm.bitmapData.threshold(photo_bd,photo_bd.rect,pnt,">",thrCol1,col1,mskCol1,true);
				photo_bdfront=sa_bm.bitmapData.clone();
				
				shot1fla=1;
				}
				else if(shot1fla==1){
				
				photo_bdback=photo_bdfront.clone();
				
				sa_bm.bitmapData.draw(video);
				
				sa_bm.bitmapData=threshold_filter(sa_bm.bitmapData);
				//photo_bm.bitmapData.threshold(photo_bd,photo_bd.rect,pnt,"<",thrCol,col,mskCol,true);
				//photo_bm.bitmapData.threshold(photo_bd,photo_bd.rect,pnt,">",thrCol1,col1,mskCol1,true);
				photo_bdfront=sa_bm.bitmapData.clone();			
				
				
				
				
				//sa_bm.bitmapData=photo_bdfront.compare(photo_bdback) as BitmapData;
				
				
				}
				
			}
			

			
			        // BitmapData#threshold()メソッド使用版
         function threshold_filter(s:BitmapData):BitmapData {
			 var threshold:uint=0x00777777;
            var d:BitmapData = new BitmapData(s.width, s.height);
            var r:Rectangle = new Rectangle(0, 0, s.width, s.height);
            d.fillRect(r, 0xFFFFFFFF); // 不透明白で塗りつぶす
            // 閾値以下を不透明黒にする
            d.threshold(s, r, new Point(0, 0), "<=",threshold, 0xFF000000, 255, false);
            return d;
        }

			
			
			
//-----------------------------------------------------------------//
//webcamの設定
//-----------------------------------------------------------------//
public function initCamera():void {
	/*接続されたWEBCAMの処理*/
			if ( camera != null ) {
				//WEBCAMの解像度とFPSを設定
				camera.setMode(320,240,30,true);
				// ビデオオブジェクト配置:サイズ指定
				video = new Video( camera.width,camera.height );
				video.x = 0;
				video.y = 0;
				// カメラ設定
				video.attachCamera( camera );
				
				// addChildで表示
				addChild( video );
			} else {
				trace("カメラが接続されていません");

			}
		}

		
		
		//-----------------------------------------------------------------//
//右側の画面の設定
//-----------------------------------------------------------------//
function initPhoto() {
	
	
	sa_bd = new BitmapData(320, 240, false, 0x00DDDDDD);
	sa_bm = new Bitmap(sa_bd);
	sa_bm.x = 0;
	sa_bm.y = 240;
	addChild(sa_bm);
	
}
		
			

	}
}