我只想启动我的网络摄像头来显示视频,为此我编写了这段代码,但它不起作用。知道为什么它一定不起作用吗?我可能会犯什么错误?
请这里是代码,
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.controls.Alert;
protected function video_d_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
var camera:Camera = Camera.getCamera();
if (camera) {
video_d.videoObject.attachCamera(camera);
} else {
Alert.show("You don't seem to have a camera.");
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VideoDisplay x="15" y="23" id="video_d" creationComplete="video_d_creationCompleteHandler(event)" />
</s:Application>
相反,我看到弹出错误:
TypeError:错误 #1009:无法访问空对象引用的属性或方法。在 vv/video_d_creationCompleteHandler()[C:\Users\Malik\Adobe Flash Builder 4.6\vv\src\vv.mxml:15] 在 vv/__video_d_creationComplete()[C:\Users\Malik\Adobe Flash Builder 4.6\vv\ src\vv.mxml:26] 在 flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.core::UIComponent/dispatchEvent()[E:\dev\4.y \frameworks\projects\framework\src\mx\core\UIComponent.as:13152] 在 mx.core::UIComponent/set initialized()[E:\dev\4.y\frameworks\projects\framework\src\mx \core\UIComponent.as:1818] 在 mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:842] 在 mx .managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.
非常感谢您的回答。谢谢比拉尔·艾哈迈德