Camera.get() 中的 MXML/AS 错误

发布于 2024-10-05 04:24:15 字数 1754 浏览 6 评论 0原文

我是 Flex/AS 编程新手 在下面的代码中,这个错误是什么以及如何解决它

     <?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();

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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷清清 2024-10-12 04:24:15

您的代码令人困惑...您显示与 myCam 相关的错误,但 myCam 已被注释掉!

我们假设错误与凸轮变量有关。你定义了凸轮吗?

     private var cam:Camera;

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

检查页面底部的示例 attachCamera ()

按照您的代码...

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

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

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 );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文