I need to use the code below to load an image from the CameraRoll with Adobe Air on iOS 8. (it will also be used to read the EXIF data from the loaded image)
I would like to add the bitmap via addChild()
to the stage as soon as the onMediaLoadedCameraRoll
function gets triggered. How to do that?
var loaderCameraRoll:Loader
var deviceCameraRoll:CameraRoll
var dataSourceCameraRoll:IDataInput;
var mediaPromiseCameraRoll:MediaPromise;
function loadImageFromCameraRoll(e:Event=null):void {
deviceCameraRoll = new CameraRoll();
deviceCameraRoll.addEventListener(MediaEvent.SELECT, onSelectCameraRoll);
deviceCameraRoll.browseForImage();
}
function onSelectCameraRoll(event:MediaEvent):void {
mediaPromiseCameraRoll = event.data;
dataSourceCameraRoll = mediaPromiseCameraRoll.open();
var eventSource:IEventDispatcher = dataSourceCameraRoll as IEventDispatcher;
eventSource.addEventListener( Event.COMPLETE, onMediaLoadedCameraRoll );
}
function onMediaLoadedCameraRoll(event:Event):void {
// display loaded image
}
The documentation says this about the matter:
This is followed by an example that does exactly that:
As seen in the example code, you should always add the listeners for a Loader to its contentLoaderInfo property.