2 Replies Latest reply on Sep 20, 2011 7:21 PM by Yue_Hong

    Displaying a webcam’s video in a Flex VideoDisplay control

    Yue_Hong Level 1

      Hi,

       

      I am trying to get flex to display webcam's video, but I keep on getting the error message of

       

      DescriptionResourcePathLocationType
      1061: Call to a possibly undefined method getCamera through a reference with static type Class.Camera.mxml/Camera/srcline 11Flex Problem
      1067: Implicit coercion of a value of type Camera to an unrelated type flash.media:Camera.Camera.mxml/Camera/srcline 15Flex Problem

       

      Here is my source code:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                             xmlns:s="library://ns.adobe.com/flex/spark" 
                             xmlns:mx="library://ns.adobe.com/flex/mx">
          <fx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  
                  private function videoDisplay_creationComplete() : void
                  {
                      var webcam:Camera = Camera.getCamera();
                      
                      if (webcam) 
                      {
                          cameraDisplay.attachCamera(webcam);                    
                      } 
                      else 
                      {
                          Alert.show("Oops, we can't find your camera.");
                      }
                  }
                  
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <mx:HBox>
              <mx:Panel title="Video">
                  <mx:VideoDisplay id="cameraDisplay" creationComplete="videoDisplay_creationComplete();" width="320" height="240" />        
              </mx:Panel>
          </mx:HBox>
          <mx:HBox>
              <s:Button label="reload camera" click="videoDisplay_creationComplete();"/>
          </mx:HBox>
      </s:WindowedApplication>
      

       

       

      How can I solve it? Thanks.