您的位置:首页 > 其它

Flex中如何监测摄像头Camera对象活动以及状态事件与信息

2009-06-08 23:33 549 查看
main.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

layout="horizontal"

verticalAlign="middle"

backgroundColor="white">



<mx:Script>

<![CDATA[

import mx.controls.Alert;

import mx.utils.StringUtil;



private function videoDisplay_creationComplete():void {

var camera:Camera = Camera.getCamera();

if (camera) {

videoDisplay.attachCamera(camera);

camera.addEventListener(ActivityEvent.ACTIVITY, camera_activity);

camera.addEventListener(StatusEvent.STATUS, camera_status);

} else {

Alert.show("You don't seem to have a camera.");

}

}



private function camera_activity(evt:ActivityEvent):void {

var str:String = "[{0}] activating:{1}/n";

textArea.text += StringUtil.substitute(str,

evt.type,

evt.activating);

}



private function camera_status(evt:StatusEvent):void {

var str:String = "[{0}] code:'{1}', level:'{2}'/n";

textArea.text += StringUtil.substitute(str,

evt.type,

evt.code,

evt.level);

switch (evt.code) {

case "Camera.Muted":

Alert.show("User denied access to camera.");

break;

case "Camera.Unmuted":

Alert.show("User allowed access to camera.");

break;

}

}

]]>

</mx:Script>



<mx:VideoDisplay id="videoDisplay"

creationComplete="videoDisplay_creationComplete();"

width="160"

height="120" />



<mx:TextArea id="textArea"

editable="false"

width="100%"

height="{videoDisplay.height}"

wordWrap="false"

verticalScrollPolicy="on" />



</mx:Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐