# How do you load BitmapData into an Array?

**URL:** <https://forum.kirupa.com/t/how-do-you-load-bitmapdata-into-an-array/301585>\
**Category:** flash\
**Created:** [December 11, 2009, 5:09pm UTC](https://forum.kirupa.com/t/how-do-you-load-bitmapdata-into-an-array/301585 "2009-12-11T17:09:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jmarshall](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@Jmarshall](https://forum.kirupa.com/u/Jmarshall)\
**Post date:** [December 11, 2009, 5:09pm UTC](https://forum.kirupa.com/t/how-do-you-load-bitmapdata-into-an-array/301585/1 "2009-12-11T17:09:48Z")

</div>

I’m loading a series of JPEGs, and I want to store them in an Array as a preload method, before distributing them to individual MCs.

My basic code (just placing them onstage to test this):

```php

picXML:XML = theXML;
for(kk=0;kk < counter;kk++) {
        var picPath:String = "images/"+picXML.element[kk].id+"_pic.jpg";
        var imageLoad = new Loader();
        imageLoad.load(new URLRequest(picPath));
        imageLoad.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

        function imageLoaded(e:Event):void {
            bitBucket = new BitmapData(imageLoad.width,imageLoad.height,false,0xffffff);
            bitBucket.draw(imageLoad, null, null, null, null, true);
            
            bitmapList[kk] = bitBucket as BitmapData;

            newPic = new Bitmap(bitmapList[kk]);
            newPic.x = 5 * kk; // offsets so images won't cover each other
            newPic.y = 5 * kk;
            addChild(newPic);
        }
}

```

But I’m doing it wrong, because only the last image gets placed on stage, and the rest are blank.

Any advice?
