# Loading external image from xml and resizing

**URL:** <https://forum.kirupa.com/t/loading-external-image-from-xml-and-resizing/265776>\
**Category:** flash\
**Created:** [July 12, 2008, 10:45am UTC](https://forum.kirupa.com/t/loading-external-image-from-xml-and-resizing/265776 "2008-07-12T10:45:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![panopticon\_](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@panopticon\_](https://forum.kirupa.com/u/panopticon_)\
**Post date:** [July 12, 2008, 10:45am UTC](https://forum.kirupa.com/t/loading-external-image-from-xml-and-resizing/265776/1 "2008-07-12T10:45:26Z")

</div>

flash cs3 timeline code:

```auto

var band_load:String = "Thrice";
var image_xml:XML;

var xmlReq:URLRequest = new URLRequest("http://ws.audioscrobbler.com/1.0/artist/"+band_load+"/topalbums.xml");
var xmlLoader:URLLoader = new URLLoader();

    function xmlLoaded(event:Event):void
    {
        
    image_xml = new XML(xmlLoader.data);
    
    
    //SIMILAR ARTISTS

    var imgLoader:Loader;
    
    
    var slide:Sprite;
    slide = new Sprite();
    //slide.width = 10;    
    //slide.height = 10;
    slide.x = 10;
    slide.y = 10;
    addChild(slide);
    
    imgLoader = new Loader();
    imgLoader.load(new URLRequest(image_xml.album[0].image.medium));
    
    slide.addChild(imgLoader);
    
    }

xmlLoader.load(xmlReq);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

```

i dont know how to resize the loaded image, if i use

```auto

slide.width = 10;    
slide.height = 10;

```

nothing is displayed :(. if i remove these 2 lines, everything works fine but my image is not the right size

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [July 12, 2008, 1:47pm UTC](https://forum.kirupa.com/t/loading-external-image-from-xml-and-resizing/265776/2 "2008-07-12T13:47:32Z")

</div>

wait until it loads

```auto
imgLoader.contentLoaderInfo.addEventListener(Event.INIT, imgLoaded);

function imgLoaded(e:Event):void {
//can use slide.width/slide.height
	e.target.content.width = 10;
	e.target.content.height = 10
}

```

---

<div class="post-metadata">

**Author:** ![panopticon\_](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@panopticon\_](https://forum.kirupa.com/u/panopticon_)\
**Post date:** [July 12, 2008, 4:30pm UTC](https://forum.kirupa.com/t/loading-external-image-from-xml-and-resizing/265776/3 "2008-07-12T16:30:11Z")

</div>

thanks, works like a charm 🙂
