ActionScript 3 在ActionScript中打开相机

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 在ActionScript中打开相机相关的知识,希望对你有一定的参考价值。

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 );

以上是关于ActionScript 3 在ActionScript中打开相机的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 在Actionscript中绘制缩放对象

ActionScript 3 在ActionScript中打开相机

将 Actionscript 1 转换为 Actionscript 3

ActionScript 3 AS3 TextField和StyleSheet示例(在ActionScript中创建)

ActionScript 2.0 和 ActionScript 3.0 有啥区别

ActionScript 3 AS3:在ActionScript中使用E4X生成动态XML