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

forked from: (ニセ)輪郭線を青く

BlendMode.DIFFERENCE で高速に
/**
 * Copyright alpicola ( http://wonderfl.net/user/alpicola )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6xIz
 */

// forked from cDa's (ニセ)輪郭線を青く

/*
BlendMode.DIFFERENCE で高速に
*/

package{
	import flash.display.MovieClip;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BitmapDataChannel;
	import flash.display.BlendMode;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.media.Video;
	import flash.media.Camera;
	[SWF(width="320", height="240", backgroundColor="#000000", frameRate="15")] 
    
	

	public class Main extends MovieClip{

		private var video:Video;
		
		private var bmpMC:MovieClip;
		private var bmp:Bitmap;
		private var bmpDat:BitmapData;
		private var bmpDat2:BitmapData;

		
		public function Main(){
			
			
			var camera:Camera = Camera.getCamera();
			
			if ( camera != null ) {
				video = new Video( 320, 240 );
				video.attachCamera( camera );
				video.visible=false;
				
				
				bmpDat = new BitmapData(video.width, video.height, false, 0x000000);
				bmpDat2 = new BitmapData(video.width, video.height, false, 0x000000);
				bmp = new Bitmap( bmpDat2 );

				bmpMC=new MovieClip();
				bmpMC.addChild( bmp );
				addChild(bmpMC);
				
				addEventListener( Event.ENTER_FRAME , capVideo );
			}
		}
		
		
		private function capVideo( e:Event ):void{
			var source:BitmapData = new BitmapData(video.width, video.height, false, 0x000000);
			source.draw(video);
			var diff:BitmapData = source.clone();
			diff.draw(bmpDat, new Matrix(), new ColorTransform(), BlendMode.DIFFERENCE);
			bmpDat2.copyChannel(diff, diff.rect, new Point(), BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
			bmpDat = source.clone();
		}
		
	}
}