Camera.get() 中的 MXML/AS 错误
我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码令人困惑...您显示与 myCam 相关的错误,但 myCam 已被注释掉!
我们假设错误与凸轮变量有关。你定义了凸轮吗?
检查页面底部的示例 attachCamera ()
按照您的代码...
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?
Check the example at the bottom of the page for attachCamera()
Following your code...