Flash CS5.5:使用iPhone上的CameraUI捕捉照片时旋转照片

问题描述:

请帮助,我已经成功地通过iphone的相机访问和捕捉照片。但问题是当我通过“loadFilePromise”加载它时,照片旋转方向错误。Flash CS5.5:使用iPhone上的CameraUI捕捉照片时旋转照片

import flash.media.CameraUI; 
import flash.media.MediaType; 
import flash.media.MediaPromise; 
import flash.events.MediaEvent; 
import flash.events.Event; 
import flash.events.MouseEvent; 
import flash.display.Loader; 
import flash.display.Bitmap; 
import flash.media.CameraRoll; 
import flash.display.StageOrientation; 
import flash.events.StageOrientationEvent; 
import flash.media.Camera; 
import flash.media.Video; 

var currentOrientation:String = ""; 

var cam:CameraUI = new CameraUI(); 
cam.addEventListener(MediaEvent.COMPLETE, captured); 
cam.addEventListener(Event.CANCEL, cancelled); 

var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, photoLoaded); 
addChild(loader); 

captureBtn.addEventListener(MouseEvent.MOUSE_UP, pressed); 

function pressed(e:MouseEvent){ 
    if(CameraUI.isSupported){ 
     cam.launch(MediaType.IMAGE); 
    } 
} 

function captured(e:MediaEvent){ 
    var mediaPromise:MediaPromise = e.data; 
    if(mediaPromise != null) 
    { 
     output.text = "Photo captured."; 
     loader.loadFilePromise(mediaPromise); 
    } 
} 

function cancelled(e:Event):void { 
    output.text = "Cancelled."; 
} 

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING,orientationChanging); 
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged); 

function orientationChanging(e:StageOrientationEvent){ 
    currentOrientation = e.afterOrientation; 
    trace(currentOrientation); 
    switch(currentOrientation) 
    { 
     case StageOrientation.DEFAULT : 
      currentOrientation = "DEFAULT"; 
      //set rotation value here 
      stage.rotation = 0; 
      break; 

     case StageOrientation.ROTATED_RIGHT : 
      currentOrientation = "ROTATED_RIGHT"; 
      //set rotation value here 
      stage.rotation = -90; 
      break; 

     case StageOrientation.ROTATED_LEFT : 
      currentOrientation = "ROTATED_LEFT"; 
      //set rotation value here 
      stage.rotation = 90; 
      break; 

     case StageOrientation.UPSIDE_DOWN : 
      currentOrientation = "UPSIDE_DOWN"; 
      //set rotation value here 
      stage.rotation = 180; 
      break; 
    } 
} 

function orientationChanged(e:StageOrientationEvent){ 

} 

function photoLoaded(e:Event){ 
    var img:Bitmap = e.currentTarget.content as Bitmap; 
    img.smoothing = true; 
    img.width = 350 
    img.scaleY = img.scaleX; 

    /* TRY THIS TO FIX BUT IT DIDN'T WORK: 
     switch(currentOrientation){ 

     case "rotatedLeft": 
      img.rotation = 90; 
     break; 

     case "rotatedRight": 
      img.rotation = 90; 
     break; 

     case "upsideDown": 

     break; 

    }*/ 

    /* THESE LINE ARE JUST USED TO SAVE PHOTO IN CAMERA ROLL: 
     if(CameraRoll.supportsAddBitmapData) 
    { 
     cameraRoll.addBitmapData(img.bitmapData); 
    }*/ 
} 

function camRollSaved(e:Event){ 
    output.text = "Your photo is saved to a camera roll." 
} 

我已经在发布设置中未选中“自动定位”,试图更正StageOrientation,但它仍然无法工作。

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING,orientationChanging); 
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged); 

这是唯一正确的,当我将iphone旋转到lanscape(相机的位置在TOP-RIGHT),然后拍照。

有没有人有同样的问题或知道如何解决它?

非常感谢,

+0

这是一个已知的错误。请到https://bugbase.adobe.com/index.cfm?event=bug&id=4070057投票,也许Adobe会修复它。 –

这解决了这个问题,我在Android上: http://blog.flexnroses.com/?p=95

我认为这是与iOS的库出了问题,所以它可能不是解决你的问题,但也许你可以从这里获得你需要的灵感。祝你好运!