# Setting the width of dynamically loaded images

**URL:** <https://forum.kirupa.com/t/setting-the-width-of-dynamically-loaded-images/274540>\
**Category:** Uncategorized\
**Created:** [October 31, 2008, 9:16am UTC](https://forum.kirupa.com/t/setting-the-width-of-dynamically-loaded-images/274540 "2008-10-31T09:16:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fideldonson](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@fideldonson](https://forum.kirupa.com/u/fideldonson)\
**Post date:** [October 31, 2008, 9:16am UTC](https://forum.kirupa.com/t/setting-the-width-of-dynamically-loaded-images/274540/1 "2008-10-31T09:16:15Z")

</div>

In a project im working on i get the following strange behaviour:  
I load an image with a loader object  
listen for the contentLoaderInfo Event.COMPLETE  
and then set the width of the target.content  
problem is that the width of the loaded image is not set.

can the COMPLETE event fire before the image is completed or what could be the problem?

here’s the code:

var shopImageLoader:Loader=new Loader();  
shop.shopItem.addChild(shopImageLoader);

shopImageLoader.load(new URLRequest(“cover\_url”)));  
shopImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onShopImageComplete);

function onShopImageComplete(evt:Event):void{  
evt.target.content.width=68;  
evt.target.content.height=68;  
}
