Posts Tagged ‘load’

Multiple Bitmap Loader in AS3

Sunday, November 25th, 2007

To aid in my projects I have written a simple bitmapData loading class entitled aquireResources. This class takes an array of image paths as strings and proceeds to load them one by one. A “complete” event is dispatched when loading is completed and the bitmapData of each loading instance are saved in an array in the order they were given. Calling the aquireResources.array() method returns the array of bitmapData. If you’ve already downloaded Thibault Imbert (bytearray.org)’s GIFPlayer and GIFDecoder classes you can uncomment the included properties and methods in my class and enable the aquireResources class to load multiple instances of animated GIFs into AS3 as arrays of bitmapData. In this case aquireResources.array() returns a two-dimensional array containing one array of bitmapData per animated GIF passed to it.

Usage

import com.efnx.utils.aquireResources;

var rsrc:aquireResources = new aquireResources();
     rsrc.addEventListener("complete", onComplete, false, 0, true);

var array:Array = new Array("imagePath1/image1.png", "imagePath2/image2.gif", "imagePath3/image3.jpeg");
var bitmapDataArray:Array;
function onComplete(event:Event):void
{
     bitmapDataArray = rsrc.array();
}

rsrc.aquireImages(array);

For loading animated GIFs

import com.efnx.utils.aquireResources;

var rsrc:aquireResources = new aquireResources();
     rsrc.addEventListener("complete", onComplete, false, 0, true);

var array:Array = new Array("imagePath1/image1.gif", "imagePath2/image2.gif", "imagePath3/image3.gif");

var animatedArray:Array;
function onComplete(event:Event):void
{
     animatedArray = rsrc.array();
}

rsrc.aquireGIFs(array);

Source
aquireResources Source


Follow me on GitHub
Follow me on Google+
Follow me on Twitter