Flash Builder 初试(三) 使用摄像头
本程序演示了,如何调用本地摄像头,并显示在FLASH中
import flash.media.Camera; import mx.events.FlexEvent; private var camera:Camera; private var video:Video; protected function btnCamera_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub if(Camera.isSupported==true) { camera=Camera.getCamera(); camera.setMode(320,240,15,true); sve.width=camera.width; sve.height=camera.height; video=new Video(camera.width,camera.height); video.attachCamera(camera); sve.addChild(video); this.lab_info.text="摄像头 ["+camera.name+"] 已经打开"; } else { this.lab_info.text="系统不支持摄像头!"; } }
<s:SpriteVisualElement id="sve" x="10" y="39" width="100" height="100"/> <s:Button id="btnCamera" x="10" y="10" label="打开摄像头" click="btnCamera_clickHandler(event)"/> <s:Label id="lab_info" x="98" y="19"/>
量的积累到质的飞越