返回顶部

收藏

Flash Builder/Flex摄像头调用

更多
//片段1
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="系统不支持摄像头!";
    }
}

//片段2
<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"/>
//该片段来自于http://outofmemory.cn

标签:flash,ActionScript,系统

收藏

0人收藏

支持

0

反对

0

发表评论