2 Replies Latest reply on Aug 15, 2011 11:02 PM by Joe ... Ward

    Problems upload photos from camera iPhone

    marthaic88 Level 1

      Hi!

       

      I am trying to develop an app for take photos and then upload it...

       

      I have this methods to show the camera and get photos

       

      public function showCamera():void{

        if (CameraUI.isSupported){                

          camera = new CameraUI();

          camera.addEventListener(MediaEvent.COMPLETE, onComplete);

          camera.launch(MediaType.IMAGE);

        }

      }

       

      private function onComplete(event:MediaEvent):void{

        var mp:MediaPromise = event.data;

        //this.image_url = mp.file.url;

      }

       

      The problem is mp.file.url is null in iPhone, I read a lot about this issue and found this solution, it is load the lastest image from the memory using loader context, i do that in this way:

       

      private function onCameraUIComplete(e:MediaEvent):void
      {
        var cameraUI:CameraUI = e.target as CameraUI;
        cameraUI.removeEventListener(MediaEvent.COMPLETE, onCameraUIComplete);
        cameraUI.removeEventListener(Event.CANCEL, onCameraUICanceled);
        cameraUI.removeEventListener(ErrorEvent.ERROR, onCameraError);
                       
        mediaPromise = e.data;
                          
        this.mpLoader = new Loader();
        this.mpLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMediaPromiseLoaded);
        this.mpLoader.addEventListener(IOErrorEvent.IO_ERROR, onMediaPromiseLoadError);
        this.mpLoader.loadFilePromise(mediaPromise);
      }
                
      private function onMediaPromiseLoaded(e:Event):void
      {
        var mpLoaderInfo:LoaderInfo = e.target as LoaderInfo;
        mpLoaderInfo.removeEventListener(Event.COMPLETE, onMediaPromiseLoaded);
        mpLoaderInfo.loader.removeEventListener(IOErrorEvent.IO_ERROR, onMediaPromiseLoadError);
        this.imgPhoto.source = mpLoaderInfo.loader;         //adding photo to image display in the screen
      //adding photo to camera roll
        var bitmapData:BitmapData = Bitmap(e.target.content).bitmapData;
        addToCamaraRoll(bitmapData);
      }
      

       

      My question is, how to convert o get the result of LoaderInfo as a File o FileReference , o how to convert Bitmap or bitmapData in a File. I need a File or FileReference to upload it an a server.