如何在移动项目中使用 Flex 4.5.1 捕获图像?
我是 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 帮助..谢谢...
I am a newbie in Flex and ActionScript programming and learning it as fast as I can. I have tried few sample applications. Now I am trying to capture the image using ActionScript through the webcam attached with the PC.
I have written following code...
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"/>
But the camera is not getting detected.. currentsState is always unsupported... Is there anything wrong...
Any other way to capture image/video for mobile devices using FlexMobileProject..?
Any blog/tutorial related to Flex Mobile Development will be of gr8 help..Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自文档:
“使用 Camera 类从客户端系统或设备摄像头捕获视频。使用 Video 类在本地监视视频。”
您应该阅读的第一件事是关于 Camera 类。
然后查看视频类。
文档中的示例:
看看您是否可以使该位工作,然后询问有关过滤图片并保存它的另一个问题。
From the docs:
"Use the Camera class to capture video from the client system or device camera. Use the Video class to monitor the video locally."
The first thing you should read is about the Camera Class.
Then check out the Video Class.
Example from the docs:
See if you can get that bit working, and then ask another question about filtering the pic and saving it.