• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Impossible to import image using browseForImage on Android

Engaged ,
Jun 08, 2018 Jun 08, 2018

Copy link to clipboard

Copied

Lately I had several users on android that wasn't able to import image from their gallery where I'm using browseForImage and MediaPromise. I checked and saw that browseForImage didn't send a valid image, just a stream with a text saying "exception thown by getter"

I filled a bug Tracker

I can't say when the problem came up, but I'm sure it was working before.

Does anyone face the same problem?

Any idea or suggestion?

here is my test code:

import flash.media.MediaPromise;

import flash.media.CameraRoll;

import flash.media.MediaType;

import flash.events.*;

var cameraRoll:CameraRoll = new CameraRoll();

cameraRoll.addEventListener( MediaEvent.SELECT, imageSelected );

cameraRoll.addEventListener( Event.CANCEL, removeListeners );

cameraRoll.addEventListener( ErrorEvent.ERROR, removeListeners );

cameraRoll.addEventListener(PermissionEvent.PERMISSION_STATUS, permissionListener);

cameraRoll.requestPermission();

var dataSource:IDataInput;

//var extension:String = "";

function permissionListener(e:PermissionEvent):void

{

trace("permissionListener", e.status);

cameraRoll.browseForImage();

}

function imageSelected( event:MediaEvent ):void

{

trace( "Media selected..." );

var imagePromise:MediaPromise = event.data;

dataSource = imagePromise.open();

if( imagePromise.isAsync )

{

trace( "Asynchronous media promise." );

var eventSource:IEventDispatcher = dataSource as IEventDispatcher;          

eventSource.addEventListener( Event.COMPLETE, onMediaLoaded );       

function onMediaLoaded( event:Event ):void

{

trace("Media load complete");

eventSource.removeEventListener( Event.COMPLETE, onMediaLoaded );

readMediaData();

}

}

else

{

trace( "Synchronous media promise." );

readMediaData();

}

}

function removeListeners( e:* = null):void

{

trace("removeListeners");

cameraRoll.removeEventListener( MediaEvent.SELECT, imageSelected );

cameraRoll.removeEventListener( Event.CANCEL, removeListeners );

cameraRoll.removeEventListener( ErrorEvent.ERROR, removeListeners );

cameraRoll = null;

}

function readMediaData():void

{

trace("done");

}

TOPICS
Performance issues

Views

334

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
community guidelines

correct answers 1 Correct answer

Engaged , Jun 09, 2018 Jun 09, 2018

I retried and the problem is gone. I don't know why...

Votes

Translate

Translate
Engaged ,
Jun 09, 2018 Jun 09, 2018

Copy link to clipboard

Copied

LATEST

I retried and the problem is gone. I don't know why...

Votes

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
community guidelines