如何在AS3中使用iOS摄像头? [英] How can you use the iOS camera in AS3?

查看:356
本文介绍了如何在AS3中使用iOS摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以在AS3应用程式中使用iOS装置的相机吗?如果是,如何?

Can you use the camera of an iOS device in an AS3 app? If so, how?

推荐答案

这是很容易,有很多方法来访问摄像机在AS3。

Yep it's really easy, there are many ways to access the camera in AS3.

首先,与在常规AS3应用程序中访问摄像机的方式相同:

Firstly, the same way as you access the camera in normal AS3 applications:

var camera:Camera = Camera.getCamera();
var video=new Video();
video.attachCamera(camera);
this.addChild(video);

这会在当前显示对象中显示摄像机。

This will display the camera in the current display object.

您也可以使用CameraRoll类向相机胶卷请求图片:

You can also ask for images from the Camera roll using the CameraRoll class:

import flash.media.CameraRoll;
var cameraRoll:CameraRoll = new CameraRoll();

if(CameraRoll.supportsBrowseForImage) 
{
    cameraRoll.addEventListener(MediaEvent.SELECT, imageSelected); 
    cameraRoll.addEventListener(Event.CANCEL, browseCancelled); 
    cameraRoll.addEventListener(ErrorEvent.ERROR, mediaError); 

    // Ask the user to select an image
    cameraRoll.browseForImage(); 
}

您可以使用本机的camera应用程序拍摄照片: p>

You can use the native "camera" application to take a photo:

import flash.media.CameraUI;

var cameraUI:CameraUI = new CameraUI();

if (CameraUI.isSupported ) 
{
    cameraUI.addEventListener(MediaEvent.COMPLETE, imageSelected); 
    cameraUI.addEventListener(Event.CANCEL, browseCancelled); 
    cameraUI.addEventListener(ErrorEvent.ERROR, mediaError); 

    cameraUI.launch(MediaType.IMAGE); 
}

希望指向正确的方向。

这篇关于如何在AS3中使用iOS摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆