Here is a sample code
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.ActivityEvent;
import flash.events.MouseEvent;
import flash.media.Camera;
import flash.media.Video;
public class iosTest extends Sprite
{
private var cam:Camera;
private var vid:Video;
public function iosTest()
{
super();
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
cam = Camera.getCamera();
if (!cam)
{
trace("No camera is installed.");
}
else
{
connectCamera();
}
}
private function connectCamera():void
{
cam.setMode(640, 480, 25);
cam.setQuality(0,100);
vid = new Video();
vid.width = cam.width;
vid.height = cam.height;
vid.attachCamera(cam);
addChild(vid);
stage.addEventListener(MouseEvent.CLICK, clickHandler);
}
private function clickHandler(e:MouseEvent):void
{
return;
switch (cam.width) {
case 160:
cam.setMode(320, 240, 10);
break;
case 320:
cam.setMode(640, 480, 5);
break;
default:
cam.setMode(160, 120, 15);
break;
}
removeChild(vid);
connectCamera();
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…