【发布时间】:2011-11-28 13:03:56
【问题描述】:
我是 Flex 和 ActionScript 编程方面的新手,并尽可能快地学习它。我尝试了几个示例应用程序。现在我正在尝试通过与 PC 连接的网络摄像头使用 ActionScript 捕获图像。
我已经写了以下代码...
protected var myCam:CameraUI;
protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
if (CameraUI.isSupported){
currentState = "normal";
myCam = new CameraUI();
myCam.addEventListener(MediaEvent.COMPLETE, onComplete);
}
else currentState = "unsupported";
}
protected function btnPic_clickHandler(event:MouseEvent):void
{
img.filters = [];
myCam.launch(MediaType.IMAGE);
}
protected function onComplete(evt:MediaEvent):void
{
img.source = evt.data.file.url;
}
protected function applyFilter():void
{
if (img.filters.length==0)
{
var matrixArray:Array = [.33,.33,.33,0,0,
.33,.33,.33,0,0,
.33,.33,.33,0,0,
0,0,0,1,0];
var blackWhiteFilter:ColorMatrixFilter = new ColorMatrixFilter(matrixArray);
img.filters = [blackWhiteFilter];
btnBW.label = "COLOR";
}
else
{
img.filters = [];
btnBW.label = "B/W FILTER";
}
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
<s:State name="unsupported"/>
</s:states>
<s:layout>
<s:VerticalLayout paddingTop="20" paddingBottom="20" paddingLeft="10" paddingRight="20" gap="40"
horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<s:Label text="This device does not support Camera." width="95%" includeIn="unsupported"/>
<s:HGroup includeIn="normal">
<s:Button id="btnPic" click="btnPic_clickHandler(event)" label="TAKE A PICTURE"/>
<s:Button id="btnBW" click="applyFilter()" label="B/W FILTER" />
</s:HGroup>
<s:Image id="img" height="649" y="124" width="460" x="10" includeIn="normal"/>
但是没有检测到摄像头.. currentsState 总是不受支持...有什么问题吗...
使用 FlexMobileProject.. 为移动设备捕获图像/视频的任何其他方式?
任何与 Flex 移动开发相关的博客/教程都会对 gr8 有所帮助..谢谢...
【问题讨论】:
标签: actionscript-3 apache-flex flexbuilder