# Loading external assets - making them reusable

**URL:** https://forum.kirupa.com/t/loading-external-assets-making-them-reusable/268392
**Category:** flash
**Created:** [August 13, 2008, 10:43am UTC](https://forum.kirupa.com/t/loading-external-assets-making-them-reusable/268392 "2008-08-13T10:43:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kotak](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@kotak](https://forum.kirupa.com/u/kotak)
#### Post date: [August 13, 2008, 10:43am UTC](https://forum.kirupa.com/t/loading-external-assets-making-them-reusable/268392/1 "2008-08-13T10:43:47Z")

</div>

Hi all!  
I’ve been using a fairly un-dynamic approach in AS3 as until now when it comes to loading assets, but now I’ll be trying to adapting a current project to fit other clients with different needs which means I’ll have to grab the bull by the horns.

I have an XML with a list of images that will be used, which is reused multiple times in each project. So I’m wondering if there’s a way to load an image using the loader-class, and making it reusable? Being able to attach said asset later to a placeholder inside a movieclip I have stored in the library would be ideal.

I managed to load it into a movieclip but duplicating it from there on was a bit of a headache, using an approach similar to this would be great(but I have personally no idea of how to implement it): [http://darylteo.com/blog/2007/11/16/abstracting-assets-from-actionscript-in-as30-asset-libraries/](http://darylteo.com/blog/2007/11/16/abstracting-assets-from-actionscript-in-as30-asset-libraries/)

Here’s the current code I’m using, in case it helps understanding what I’m after(it’s most likely really ugly compared to what you SHOULD be doing in as3):

```auto

//Function called when XML has been loaded
function xmlLoaded(event:Event):void 
{
    var cfgXML:XML = new XML(cfgLoader.data);
    var extLength:Number = cfgXML.imagelist.children().length();
    for(var i:Number = 0; i < extLength; i++)
    {
        extArr.push(cfgXML.imagelist.ext*.attribute("filetype"));
        fileExtension += "*."+extArr*+"; ";
        extImages.push(extArr*+"_mc");
        var url:String = "images/"+extArr*+".png";
        extLoader* = new Loader();
        var extReq:URLRequest = new URLRequest(url);
        extLoader*.load(extReq);
        extImages* = new MovieClip();
        this.addChild(extImages*);
        extImages*.addChild(extLoader*);
        extImages*.x = 10;
        extImages*.y = -1500;
    }
    isXmlLoaded = true;
}

```

Basically I’m loading the image into a movieclip with the same name as the imagename, but with a \_mc in the end.

Hope this makes some sense 🙂  
Please help a newbie out!
