Highlighted

Unable to use iOS CameraRoll and browseForImage with Air 15

Community Beginner ,
Oct 09, 2014

Copy link to clipboard

Copied

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);
          }
     }
}

TOPICS
Development

Views

855

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Unable to use iOS CameraRoll and browseForImage with Air 15

Community Beginner ,
Oct 09, 2014

Copy link to clipboard

Copied

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);
          }
     }
}

TOPICS
Development

Views

856

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 09, 2014 0
New Here ,
Oct 09, 2014

Copy link to clipboard

Copied

I have same problem ...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 09, 2014 0
Explorer ,
Oct 10, 2014

Copy link to clipboard

Copied

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)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 10, 2014 0
Participant ,
Oct 10, 2014

Copy link to clipboard

Copied

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);

}

}


Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 10, 2014 0
Adobe Employee ,
Oct 10, 2014

Copy link to clipboard

Copied

Hi All,

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

Regards,

Jitender

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 10, 2014 0
shawnb81 LATEST
Explorer ,
Nov 28, 2014

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 28, 2014 1
New Here ,
Nov 19, 2014

Copy link to clipboard

Copied

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 19, 2014 0
New Here ,
Nov 27, 2014

Copy link to clipboard

Copied

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 27, 2014 0