/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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 );