MXML/AS error in Camera.get()

i am new to flex/AS programming In the below code what is this error and how to resolve it

     <?xml version="1.0" encoding="utf-8"?>
     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


     <mx:Script>
             <![CDATA[
             import mx.controls.Button;
             import mx.controls.Alert;
             import flash.media.Camera;

             public function clickhandler(event:Event):void
             {

                var button:Button=event.target as Button;
                if (button.label=='Test camera')
                {
                       mx.controls.Alert.show("Starting camera1");
                       //myCam = Camera.get();
                       //myVid.attachVideo(myCam);
                       if (Camera.names.length > 0) {
                          cam = Camera.getCamera();
                          if (cam != null) {
                             try
                             {
                                cam.setMode(160,120,8,false); // error here
                                participantVideo.attachCamera(cam);
                                psPublish.attachCamera(cam);
                             }
                             catch(err:Error)
                             {
                                Alert.show("Cannot connect camera");
                             }
                          }
                       }

                ]]>

             </mx:Script>
            <mx:Button id="button1" label="Test camera" width="100" click="clickhandler(event)" />

        </mx:Application>




     /home/tom/programs/flex/camera.mxml(19):  Error: Access of undefined property myCam.

        cam = Camera.getCamera();

Answers


Your code is confusing... you show an error related to myCam, but myCam is commented out!

Let's assume that the error has to do with the cam variable. Have you defined cam?

     private var cam:Camera;

     //or
     var cam:Camera = Camera.getCamera();

Check the example at the bottom of the page for attachCamera()

Following your code...

     private var participantVideo:Video = new Video( 160 , 120 );

     //later in your function
     participantVideo.attachCamera( cam );

Need Your Help

Change overall tintColor and font-size of UITableViewCellStyleValue2 textLabel in iOS 7

ios uitableview ios7 tintcolor

I have a Skinning module where I define my app wide tintColor for general use in the app:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.