Skip to main content
Participant
October 9, 2014
Question

Unable to use iOS CameraRoll and browseForImage with Air 15

  • October 9, 2014
  • 4 replies
  • 1147 views

If I publish with Air 14.0.0.137 it works works just fine, but when I test Air 15.0.0.302 (or Air 15.0.0.289) it's crashing.

I'm testing the following code and it's not working with AIR 15, Flash CC.

The app crashes on the device (as did my original code, hence my testing :).

I've tested on an iPhone 6 and an iPhone 5, both iOS 8.02, only using newly taken photos.

I need to use AIR 15 in my app so I'm pretty much stuck right now.

// air 14.0.0.137 WORKING (but can't be uploaded in Application Loader)

// air 15.0.0.289 NOT WORKING
// air 15.0.0.302 NOT WORKING

package
{
     import flash.display.Bitmap;
     import flash.display.BitmapData;
     import flash.display.Loader;
     import flash.display.Sprite;
     import flash.display.StageAlign;
     import flash.display.StageScaleMode;
     import flash.events.Event;
     import flash.events.IOErrorEvent;
     import flash.events.MediaEvent;
     import flash.media.CameraRoll;
     import flash.media.MediaPromise;

     public class main extends Sprite
     {
          public var imgLoader:Loader;
          public var cam:CameraRoll;
          public var promise:MediaPromise;
          public function main()
          {
               // support autoOrients
               stage.align = StageAlign.TOP_LEFT;
               stage.scaleMode = StageScaleMode.EXACT_FIT;
               cam = new CameraRoll();
               cam.browseForImage();
               cam.addEventListener(MediaEvent.SELECT,onSelect);
          }

          public function onSelect(e:MediaEvent):void{
               promise =  e.data as MediaPromise
               addToStage();
          }

          public function addToStage():void {

               imgLoader = new Loader();
               imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,drawBitmap);
               imgLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerIOErrorEventHandler);
               imgLoader.loadFilePromise(promise);

          }

          protected function errorHandlerIOErrorEventHandler(event:Event):void
          {
               trace("here");
          }
          public function drawBitmap(e:Event):void{
               var myBitmapData:BitmapData = new BitmapData(200,200);
               var image:Bitmap = new Bitmap(myBitmapData);
               image.bitmapData = Bitmap(e.currentTarget.content).bitmapData
               image.width = image.height = 200
               image.x = image.y = 50
               addChild(image);
          }
     }
}

This topic has been closed for replies.

4 replies

Participant
November 19, 2014

I'm using Air 15.0.0.356 and iOS 8.1.1 With iOS SDK 8.1 and the following really simple CameraRoll browserForImage woks on an iPhone but not the iPad (I have an iPAD Mini).

var roll:CameraRoll = new CameraRoll();

roll.browseForImage();

The above launches the Image selector however when ever I click on one of the galleries it closed without going into them...

Participant
November 27, 2014

Any updates to this issue with Air 15.0.0.356, I haven't changed my code the browseFormImage() just stopped working with this new version, please help...

Infin8
Inspiring
October 10, 2014

I've just tested my app using 15.0.0.302 with iOS 8.0.2 on an iPad mini retina and everything seems to work OK.

Built with Flash Pro CC 2014.

Here's the code snippet if it's any use.

if (CameraRoll.supportsBrowseForImage) {

  if (!_cameraRoll){

  _cameraRoll = new CameraRoll();

  }

  _cameraRoll.browseForImage();

  _cameraRoll.addEventListener(MediaEvent.SELECT, imageSelected, false, 0, true);

  _cameraRoll.addEventListener(Event.CANCEL, imageSelectionCancled, false, 0, true);

  }

private function imageSelected(event:MediaEvent):void {

  _cameraRoll.removeEventListener(MediaEvent.SELECT, imageSelected);

  _cameraRoll.removeEventListener(Event.CANCEL, imageSelectionCancled);

  var mediaPromise:MediaPromise = event.data;

  loader = null;

  loader = new Loader();

  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, photoLoader_complete, false, 0, true);

  loader.loadFilePromise(mediaPromise);

  }

private function imageSelectionCancled(event:Event):void {

  _cameraRoll.removeEventListener(MediaEvent.SELECT, imageSelected);

  _cameraRoll.removeEventListener(Event.CANCEL, imageSelectionCancled);

  _cameraRoll = null;

  }

private function photoLoader_complete(e:Event):void {

loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, photoLoader_complete);

imageBitmap = e.target.content;

        

if(imageBitmap != null){

imageBitmap.smoothing = true;

addChild(imageBitmap);

}

}


Adobe Employee
October 10, 2014

Hi All,

Next Beta build will have the fix for this problem, Apologies for the inconvenience caused

Regards,

Jitender

Known Participant
November 28, 2014

Jitender thakur wrote:

Hi All,

Next Beta build will have the fix for this problem, Apologies for the inconvenience caused

Regards,

Jitender

The CameraRoll needs a good overhaul for a number of different issues on Android as well. Check out this thread here:
Please support CameraRoll properly on Android

Would it be possible to have someone take a good look at the whole API, making sure it's working on Android 5.0 and can also load remote images (Google+, Picassa, etc)?

Would really appreciate it. I have a full line of Photo Editors, with >4million downloads, and they are severely affected by these issues.

Inspiring
October 10, 2014

I'm using air 15.0.0.249 and it works for me, however all the betas after that crashes my app. I'm working right from the timeline and with the camera roll-code from adobe.com.

Some visual bugs:

- A thick white line appears from the bottom and goes up before expanding to normal view, and you can browse/ select image. This is only on iOS 8 with iPod and iPhone. It's the same with Air 14.

- On iPad the status bar becomes visible after you browse for images, and it's stuck when you close the camera roll. Also only with iOS 8 (and 8.1 betas)

October 10, 2014

I have same problem ...