Return to Snippet

Revision: 36167
at November 19, 2010 01:42 by jefftimesten


Initial Code
if(Camera.names.length==0)
{
	var _txt:TextField = new TextField();
	_txt.thickness=5;
	_txt.textColor = 0xFF0000;  
	_txt.width = stage.width;
	_txt.text = "There is no usable camera.";
	addChild( _txt );
	return;
}

// Get the default camera
var _cam:Camera = Camera.getCamera();

// If that doesn't work, look for one named "USB Video Class Video"
// This is mostly for Mac
if(!_cam) {
	var index:int = 0;
	for ( var i : int = 0 ; i < Camera.names.length ; i++ ) {
		if ( Camera.names[ i ] == "USB Video Class Video" ) 
			index = i;
	}
	_cam = Camera.getCamera( String( index ) );
}

// If we still don't have a cmaera, open the security panel
if(!_cam) {
	Security.showSettings( SecurityPanel.CAMERA );
}				

_cam = Camera.getCamera();
_cam.setMode( 640, 480, 12, true );

_video = new Video( _cam.width, _cam.height );
_video.attachCamera( _cam );

Initial URL


Initial Description


Initial Title
Open a camera in ActionScript

Initial Tags


Initial Language
ActionScript 3