I import all necessary classes. Also I import BulkImageLoaderEvent Class so that I can use this event. I declared all required variables. In constructor function I got Array which contain list of images path. loadImage() function loads images having path in ImgArr Array with index currImgLoaded. Imgurl Loader have EventListener to  tell that image is loaded or there is file error.

On imgLoaded function I check with counter whether all images are loaded or not if not loaded I call loadImage() function again. So that I can load next image.

Now use of our custom event,

dispatchEvent(new BulkImageLoaderEvent(BulkImageLoaderEvent.SINGLE_LOAD_COMPLETE,imgLoadedArray,e.target.loader.content,true,false))


dispatchEvent(new BulkImageLoaderEvent(BulkImageLoaderEvent.ALL_LOAD_COMPLETE,imgLoadedArray,e.target.loader.content,true,false))

 here I dispatched BulkImageLoaderEvent of type SINGLE_LOAD_COMPLETE. Where single image is loaded and passes e.target.loader.content as its paramBit variable’s data. If error occurs I passed null value.

 And when all files loaded I dispatched BulkImageLoaderEvent of type ALL_LOAD_COMPLETE and passes Array of all loaded bitmaps as its paramArr variable’s data.


Timeline Code

 mainTimeLine in fla file:

import BulkImageLoader;

 var xmlReq:URLRequest=new URLRequest("gal.xml")

var xmlurl:URLLoader=new URLLoader();

var imgReqArr:Array=new Array();

var imgLabelArr:Array=new Array();

var startX=0;

var bulkImageLoader:BulkImageLoader;

var GalXML:XML



function xmlLoaded(e:Event)


            GalXML=new XML(e.target.data);


            for(var i=0;i<GalXML.img.length();i++)





            bulkImageLoader=new BulkImageLoader(imgReqArr)




function AllImgLoaded(e:BulkImageLoaderEvent)




function SingleImgLoaded(e:BulkImageLoaderEvent)




                        trace("bitmap data not present")





Here I imported BulkImageLoader class so that I can use it.

Here I put my business logic. I loaded XML file , parse it and while creating instance of BulkImageLoader Class I sent an Array which contain path of all files.

And finally I assign BulkImageLoaderEvent of types ALL_LOAD_COMPLETE and SINGLE_LOAD_COMPLETE.  

When ALL_LOAD_COMPLETE event occurs I got all bitmaps which are loaded through e.paramArr

And current loaded bitmap through e.paramBit in SINGLE_LOAD_COMPLETE event type.

That is the power of custom event. Now I can reuse this code whenever I want.