4 Replies Latest reply on Mar 22, 2012 4:07 AM by Luca Finocchio IdeaIT

    Why the camera StatusEvent method is not working in Flex 4.6 Desktop Application?

    Luca Finocchio IdeaIT

      Hi,

      I have a simple Desktop Application (working with adobe AIR) that retrieves the web camera, adds two EventListener (activity and status event) and starts the preview.

       

      The activity event method is working correctly while the status event method to notificate the correct connection is never thrown.

       

      Here is the method to initialize and start the web camera.

       

      private function videoDisplay_creationComplete():void 
      {
                camera = Camera.getCamera();
                camera.setMode(320,240,15,false);
                camera.setKeyFrameInterval (4);
                camera.setQuality (0,100);
      
      
                videoDisplay.attachCamera(camera);
      
      
                if (camera) 
                {
                          camera.addEventListener(ActivityEvent.ACTIVITY, camera_activity);
                          camera.addEventListener(StatusEvent.STATUS, camera_status);
                } 
                else 
                          textArea.text += "Nessuna camera disponibile.";
      }
      
      //Listener chiamato quando il video o il microfono vengono attivati/disattivati
      private function camera_activity(evt:ActivityEvent):void 
      {
                var str:String = "[{0}] activating:{1}\n";
      
                textArea.text += StringUtil.substitute(str,
                          evt.type,
                          evt.activating);
      }
      
      
      //Listener chiamato quando lo stato della webcam cambia
      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;
                }
      }
      
      
      

       

      Thanks in advance.

      Greetings