我正在尝试使用flash / as3拍摄静态照片并按照the example from Adobe
因此我的AS文件中的代码是
package {
import flash.desktop.NativeApplication;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MediaEvent;
import flash.media.CameraUI;
import flash.media.MediaPromise;
import flash.media.MediaType;
public class CameraUIStillImage extends MovieClip{
private var deviceCameraApp:CameraUI = new CameraUI();
private var imageLoader:Loader;
public function CameraUIStillImage() {
this.stage.align = StageAlign.TOP_LEFT;
this.stage.scaleMode = StageScaleMode.NO_SCALE;
if( CameraUI.isSupported )
{
trace( "Initializing camera..." );
deviceCameraApp.addEventListener( MediaEvent.COMPLETE, imageCaptured );
deviceCameraApp.addEventListener( Event.CANCEL, captureCanceled );
deviceCameraApp.addEventListener( ErrorEvent.ERROR, cameraError );
deviceCameraApp.launch( MediaType.IMAGE );
}
else
{
trace( "Camera interface is not supported.");
}
}
private function imageCaptured( event:MediaEvent ):void
{
trace( "Media captured..." );
var imagePromise:MediaPromise = event.data;
if( imagePromise.isAsync )
{
trace( "Asynchronous media promise." );
imageLoader = new Loader();
imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );
imageLoader.addEventListener( IOErrorEvent.IO_ERROR, cameraError );
imageLoader.loadFilePromise( imagePromise );
}
else
{
trace( "Synchronous media promise." );
imageLoader.loadFilePromise( imagePromise );
showMedia( imageLoader );
}
}
private function captureCanceled( event:Event ):void
{
trace( "Media capture canceled." );
NativeApplication.nativeApplication.exit();
}
private function asyncImageLoaded( event:Event ):void
{
trace( "Media loaded in memory." );
showMedia( imageLoader );
}
private function showMedia( loader:Loader ):void
{
this.addChild( loader );
}
private function cameraError( error:ErrorEvent ):void
{
trace( "Error:" + error.text );
NativeApplication.nativeApplication.exit();
}
}
}
在我的时间轴上我正在打电话
import CameraUIStillImage;
var cameraUIStillImage:CameraUIStillImage = new CameraUIStillImage();
addChild(cameraUIStillImage);
这会产生错误
未找到类型或不是编译时常量:MediaType
我在谷歌上发现的所有这类问题的解决方案都没有对我有所帮助。 任何人都知道什么是错的? :)
谢谢!
答案 0 :(得分:1)
MediaType.IMAGE
适用于AIR> = 2.5,因此您必须为该目标进行部署,否则它将无法正常工作。