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");
}
I retried and the problem is gone. I don't know why...
Copy link to clipboard
Copied
I retried and the problem is gone. I don't know why...