# Size of movieclip with image

**URL:** <https://forum.kirupa.com/t/size-of-movieclip-with-image/308270>\
**Category:** Uncategorized\
**Created:** [April 20, 2010, 1:18pm UTC](https://forum.kirupa.com/t/size-of-movieclip-with-image/308270 "2010-04-20T13:18:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krazycat](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@krazycat](https://forum.kirupa.com/u/krazycat)\
**Post date:** [April 20, 2010, 1:18pm UTC](https://forum.kirupa.com/t/size-of-movieclip-with-image/308270/1 "2010-04-20T13:18:14Z")

</div>

I’m not the first one who struggle with this problem, I know, but I just can’t find out how to do!

I have a loop where I load a couple of images and I want to place them in the y-axis on stage, with 20 pixels space between them. To do this I have to know the height of each image, but as you know, I can’t get the image height before it completed loading.

I really don’t want to do one loop for the loading, and another loop for the placing. Can you do it in another way?

```auto

for (var i=0;i<productXml.productCategory.product.length();i++) { 
        var product_mc:MovieClip = new MovieClip();
        
        var imgLoader:Loader = new Loader();
        imgLoader.name = "imgLoader";
        product_mc.addChild(imgLoader);
        imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImg);
        imgLoader.load(new URLRequest("products/" + productXml.productCategory.product*.imgUrl));
        
        product_mc.y = placeProduct; // placeProduct is 0 from start
        placeProduct += product_mc.height + 20; // product_mc.height is always 0 because the image haven't complete loading at this time
        addChild(product_mc);
    }
}

function loadImg(e:Event): void {
    var loaderInfo:LoaderInfo = e.target as LoaderInfo;
    var dispObj:DisplayObject = loaderInfo.content;
};

```
