Return to Snippet

Revision: 32813
at October 2, 2010 12:51 by bshantz


Initial Code
package  {
	
	import flash.media.Camera;
	import flash.media.Video;
	
	
	public class CameraDemo extends Video {
		
		private var camera:Camera;
		private var camQuality:int = 80;
		private var fps:int = 30;
		
		public function CameraDemo(w:Number = 640, h:Number = 480) {
			/*	Set the width and height of the camera's display  */
			this.width = w;
			this.height = h;
			startCamera();
		}
		
		public function startCamera():void 
		{
			/*	Get the default camera for the system	*/
			camera = Camera.getCamera();
			/* Set the bandwidth and camera image quality	*/
			camera.setQuality(0, camQuality);
			/*	Set the size of the camera and frames per second   */
			camera.setMode(this.width, this.height, fps);
			/*	Attach the camera to the video object.. In this case the current class.  */
			this.attachCamera(camera);
		}
	}
}

Initial URL
http://www.commandreturn.com/demos/cameraDemo/camera.html

Initial Description
Using the webcam in AS3 is super easy.  You just need to attach the camera class to a video instance.  This is a class that extends the video component for easily implementing a webcam display.

Initial Title
Webcam with AS3

Initial Tags
video

Initial Language
ActionScript 3