# How to load all the images

**URL:** <https://forum.kirupa.com/t/how-to-load-all-the-images/284150>\
**Category:** flash\
**Created:** [March 16, 2009, 1:22am UTC](https://forum.kirupa.com/t/how-to-load-all-the-images/284150 "2009-03-16T01:22:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [March 16, 2009, 1:22am UTC](https://forum.kirupa.com/t/how-to-load-all-the-images/284150/1 "2009-03-16T01:22:18Z")

</div>

Hi,

I’m trying to load all the images to display on the stage from an xml file.  
I am also trying to add them onto the stage using the Bitmap class. This is where I am having trouble. I am using the Bitmap class so I can use their width and height.

Right now I’m only able to see one image on stage when I use the Bitmap class. If I don’t use the Bitmap class and just addChild(iconLoader) inside the loop in the xmlLoaded function I can see all of the images. But I want to use the Bitmap class.

What am I missing or what am I doing wrong

Here is the code

```auto
 package {
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;

    public class Icon02 extends Sprite {
        private var xml:XML;
        private var xmlList:XMLList;
        private var xmlLoader:URLLoader=new URLLoader;//creates a new URL loader. xmlLoader
        private var iconLoader:Loader;//=new Loader();// // creates a new loader. iconLoader
        private var i:int;

        public function Icon02() {
            xmlLoader.load(new URLRequest("Icon.xml"));//load Icon.xml

            / ***********************Event handlers********************** /
            xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);// xmlLoader complete call function xmlLoaded

        }
        function xmlLoaded(evt:Event):void {
            xml=XML(evt.target.data);
            xmlList=xml.children();

            for (i=0; i < xmlList.length(); i++) {
                iconLoader=new Loader() ;// creates a new loader. IconLoader
                iconLoader.load(new URLRequest(xmlList*.attribute("icon")));//load icon from xml file
                iconLoader.x = i * 50;
                iconLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,iconLoaded);// iconlLoader complete call function iconlLoaded
                //addChild(iconLoader);
            }
        }//xmlLoaded

        function iconLoaded(evt:Event):void {

            var image = Bitmap(evt.target.loader.content);
            //image.x = i * 50;
            addChild(image);

        }
    }//Icon02
}//package

```

Thanks  
vxd
