# Loader/getchildbyname question

**URL:** <https://forum.kirupa.com/t/loader-getchildbyname-question/311203>\
**Category:** flash\
**Created:** [June 30, 2010, 3:08am UTC](https://forum.kirupa.com/t/loader-getchildbyname-question/311203 "2010-06-30T03:08:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![holborner](https://avatars.discourse-cdn.com/v4/letter/h/df788c/32.png) [@holborner](https://forum.kirupa.com/u/holborner)\
**Post date:** [June 30, 2010, 3:08am UTC](https://forum.kirupa.com/t/loader-getchildbyname-question/311203/1 "2010-06-30T03:08:53Z")

</div>

Hi all, AS3 beginner here 🙂  
I’m trying to do load in images from XML. And I need to assign a “title” variable to each image that gets added into a big container MC.

I tried to trace its existance by doing trace(container\_mc.getChildByName(“collection1”));

But I ended up getting “null” or “[object Loader]”

So getChildByName only works with DisplayObjects by the looks of it. If that’s the case will I have to place the image Loader into another MovieClip in the XML loop?

Thanks in advance!

```auto

function loadImages(collectionList:XML):void {
            var imageList:XMLList=collectionList.collection.img;
            var titleList:XMLList=collectionList.collection.title;
            createContainer();
            for (var i:Number=0; i<imageList.length(); i++) {

                var img_url=imageList*;
var img_title=titleList*;
                var img_loader=new Loader ;
                img_loader.load(new URLRequest(img_url));
                img_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoaded);
                img_loader.x=350*i;

                img_loader.name="collection"+i;
                
            }
        }

        function createContainer():void {
            containerHeight=350;
            containerWidth=2100;
            container_mc=new MovieClip();
            container_mc.y=stage.stageHeight/2-containerHeight/2;
            container_mc.x=stage.stageWidth/2-containerWidth/2+175;
            addChild(container_mc);

        }
        function imageLoaded(e:Event):void {
            var my_thumb:Loader=Loader(e.target.loader);
            container_mc.addChild(my_thumb);

            my_thumb.alpha=0;
            TweenLite.to(my_thumb,0.5,{alpha:1,ease:Quint.easeInOut});

            trace(container_mc.getChildByName("collection1"));
        }

```
