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: webcam

Get Adobe Flash player
by fakestar0826 05 Dec 2009
// forked from llcheesell's webcam
package {

	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.*;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.media.Camera;
	import flash.media.Video;

	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="60")]
	public class CameraView extends Sprite {

		private var video:Video;
		private var cameraBmp:Bitmap;
		private var cameraBmpData:BitmapData;

		public function CameraView() {

			var camera:Camera = Camera.getCamera();
			//camera.setMode(465,465,30);

			if (camera != null) {
				video = new Video(465,465);
				video.attachCamera(camera);
				addChild(video);
			} else {
				trace("error");
			}

			/*cameraBmpData = new BitmapData(465,465,false,0xaaaaaa);
			cameraBmp = new Bitmap(cameraBmpData);
			cameraBmp.x = 465;*/
			
			var source:BitmapData = new BitmapData(465, 465);
			source.draw(video);
			var dest:BitmapData = new BitmapData(465, 465); 
			var rec:Rectangle = new Rectangle(0, 0, 465, 465);
			dest.fillRect(rec, 0xFFFFFFFF);
			dest.threshold(source, rec, new Point(0, 0), "<=", 125, 0xFF000000, 255,false);
			var img:Bitmap = new Bitmap(dest);
			addChild(img);
			
			img.x = 465;
		}

	}
}