# Preload all xml content

**URL:** <https://forum.kirupa.com/t/preload-all-xml-content/306285>\
**Category:** Uncategorized\
**Created:** [March 12, 2010, 9:06am UTC](https://forum.kirupa.com/t/preload-all-xml-content/306285 "2010-03-12T09:06:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![junior\_kimbroug](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@junior\_kimbroug](https://forum.kirupa.com/u/junior_kimbroug)\
**Post date:** [March 12, 2010, 9:06am UTC](https://forum.kirupa.com/t/preload-all-xml-content/306285/1 "2010-03-12T09:06:42Z")

</div>

Hello!

I need some ideas on how to preload all content in a xml list into my flash project.

This is how I load the xml content today:

```auto
function xmlLoaded2(event:Event):void
{
    xml2 = XML(event.target.data);
    xmlList2 = xml2.children();
    for(i = 0; i < xmlList2.length(); i++)
    {
        
        imageLoader2.load(new URLRequest(xmlList2*.attribute("source")));
        trace("number of pictures:"+i);
vaxla();

```

vaxla and the onComplete function are the functions that adds the current media to the stage they looks like this:

```auto
    

if (j <= i){
        
        imageLoader2.load(new URLRequest(xmlList2[j].attribute("source")));
                imageLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
           imageLoader2.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
        
        addChild(imageLoader2);
        
        loadText();
        goHeadings();
    
        
        trace("j="+j);
        trace("i="+i);
        
        
    }
    else{
        
        j = 0;
        imageLoader2.load(new URLRequest(xmlList2[j].attribute("source")));
        addChild(imageLoader2);
        loadText();
        trace("j="+j);
        trace("i="+i);
        
    }

```

onComplete looks like this:

```auto

function onComplete(event:Event):void {
    progressTxt.text = "";
    //trace("count is " +count+ " of " +lastImage);

    
        mc_loader.addChild(imageLoader2);

```

i got this preloader function today but it only preloads the current media:

```auto

function progressHandler(event:ProgressEvent):void {
    var percent:Number = 0; 
    var loaded:Number = 0;
    var total:Number = 0;
    
    
       loaded += imageLoader2.contentLoaderInfo.bytesLoaded;
    total += imageLoader2.contentLoaderInfo.bytesTotal;
    percent = loaded / total;
    //LoaderBarMC.progressBar.scaleX = percent; //scaleX is a value from 0.0 to 1.0
    
    //progressTxt.text = "Loading"+loaded()"of"+total();
    progressTxt.text = Math.floor(100 * percent) + "%";
    trace("bytesLoaded=" + loaded + " bytesTotal=" + total);
}

```

so any ideas how i can load everything at the start? 🙂

kind regards  
rob
