# Loading multiple images dynamically

**URL:** <https://forum.kirupa.com/t/loading-multiple-images-dynamically/254377>\
**Category:** flash\
**Created:** [March 11, 2008, 2:23pm UTC](https://forum.kirupa.com/t/loading-multiple-images-dynamically/254377 "2008-03-11T14:23:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m0nk3y](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@m0nk3y](https://forum.kirupa.com/u/m0nk3y)\
**Post date:** [March 11, 2008, 2:23pm UTC](https://forum.kirupa.com/t/loading-multiple-images-dynamically/254377/1 "2008-03-11T14:23:29Z")

</div>

Hi Folks

Would appreciate some help on this AS3.0 problem. I’m reading an XML file no problem and getting a list of images.

The problem I’m having is trying to get them to load into dynamic movie clips.

The code is below if anyone can help, I’d be very grateful.

```auto

package {
    import flash.display.*;
    import flash.events.*;
    import flash.ui.Keyboard;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.*;

    public class MyContent extends MovieClip {
        private var externalXML:XML;
        private var loader:URLLoader = new URLLoader();
        private var request:URLRequest = new URLRequest("five.xml");
        private var myLoader:Loader = new Loader();
        private var yPos=0;

        public function MyContent() {
            init();
        }
        private function init():void {
        
            loader.addEventListener(Event.COMPLETE, onComplete);
            loader.load(request);
            
        }

        public function onComplete(event:Event):void {
            var loader:URLLoader = event.target as URLLoader;
            if (loader != null) {
                externalXML = new XML(loader.data);
                var pictLdr:Loader = new Loader();
                var max:Number = externalXML.entry.length();
                trace(max);
                for (var i:uint=0; i < max; i++) {
                    var mc:MovieClip= new MovieClip();
                    mc.name="clip"+i
                    stage.addChild(mc);
                    mc.addChild(myLoader);
                    trace(externalXML.entry*.img);
                    var url:URLRequest = new URLRequest(externalXML.entry*.img);
                    myLoader.load(url);
                    mc.x=0;
                    mc.y=yPos;
                    yPos+=150;
                    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
                    function imgLoaded(event:Event):void {
                        trace("image Loaded");
                    }
                }
                
            } else {
                trace("loader is not a URLLoader!");
            }
        }
        public function linkHandler(linkEvent:TextEvent):void {
            trace(linkEvent.text);
        }
    }
}

```

I am managing to trace that they’re all loaded, they just don’t display! Yet it works with 1 when not using the for loop.

Monkey
