I would like to take an image my application loads via HTTP and add it to the CameraRoll on an application that supports both Android and iOS devices.
Use the Loader class to load the image and then add the loaded BitmapData object to the CameraRoll
First, create a Loader object that takes care of loading the image via HTTP. After the loading is finished, grab the BitmapData from the Loader and add it to the CameraRoll.
private function loadImage(urlToImage:String):void
{
// create the Loader
var loader:Loader = new Loader();
// add listener
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
// load the image
loader.load(new URLRequest(urlToImage));
}
private function completeHandler(event:Event):void
{
// check if we can add to the CameraRoll
if (CameraRoll.supportsAddBitmapData)
{
var loader:Loader = LoaderInfo(event.target).loader;
var cameraRoll:CameraRoll = new CameraRoll();
// add the BitmapData (which lives in the Bitmap loaded by the Loader)
// to the CameraRoll
cameraRoll.addBitmapData((loader.content as Bitmap).bitmapData);
}
}
+