Flash Builder4.6开发
flex4中调用摄像头时出现雪花点如下图所示:
  以下是源码:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" title="主页视图">
        
        <fx:Script>
                <![CDATA[
                        
                        private var cam:Camera = Camera.getCamera(); 
                        
                        private function vid_creationComplete():void
                        {
                                
                                var vid:Video = new Video();
                                
                                
                                if (cam) 
                                { 
                                        if ((cam.width == -1) && ( cam.height == -1))
                                        {
                                                
                                                vid.width  = 0;
                                                vid.height = 0;
                                                trace("No camera!");
                                        }
                                        else
                                        {
                                                cam.addEventListener(StatusEvent.STATUS,statusHandler); 
                                                cam.addEventListener(ActivityEvent.ACTIVITY,activityHandler); 
                                                
                                                
                                                cam.setMode(320,472,15,true);
                                                cam.setQuality(0, 85);
                                                
                                                vid.width  = cam.width;
                                                vid.height = cam.height;        
                                                
                                                vid.attachCamera(cam);
                                                vidDisplay.addChild(vid);
                                        }
                                }
                                else
                                {
                                        trace("User has no cameras installed."); 
                                }
                        }
                                
                        private function statusHandler(evt:StatusEvent):void{ 
                                if(cam.muted){
                                        trace("不能使用");
                                        cam.removeEventListener(StatusEvent.STATUS ,statusHandler);
                                }
                        } 
                        
                        private function activityHandler(evt:ActivityEvent):void{ 
                                if(evt.activating){ 
                                        trace("检测开始"); 
                                } 
                                else{ 
                                        trace("检测停止"); 
                                } 
                        }        
                        
                        
                ]]>
        </fx:Script>
        
        <fx:Declarations>
                <!-- 将非可视元素(例如服务、值对象)放在此处 -->
        </fx:Declarations>
        
        <s:VideoDisplay id="vidDisplay" left="0" right="0" top="0" bottom="0"
                                        creationComplete="vid_creationComplete()">
        </s:VideoDisplay>
        
</s:View>
其中trace出:
检测开始
检测停止
检测开始
检测停止
检测开始
检测停止
检测开始
检测停止


flexcamvideo