XML Preload Progress Bar

Hey’a!

Can someone please source me some code that preloads XML with a progress bar / percentage and once it has done that, reads from the XML file - Because atm, I have a progress bar and it loads etc etc, but then if I do a “preview with certain internet speed” it doesn’t load the XML properly?

Heres my code:

Frame1


feature_name = "intro";

bar._visible = false;
pText._visible = false;

var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("snow.xml");

this.createEmptyMovieClip("xmlPreload", this.getNextHighestDepth());
xmlPreload.onEnterFrame = function(){
    gotoAndStop(1);
    var xmlLoaded:Number = xmlData.getBytesLoaded();
    var xmlTotal:Number = xmlData.getBytesTotal();
    var xmlPercent:Number = xmlLoaded/xmlTotal;
    var xmlScale = xmlPercent*100;
    if (isNaN(xmlScale) == false) {
        bar._visible = true;
        pText._visible = true;
    }
    trace(Math.floor(xmlScale)+" Before Del");
    bar._xscale = xmlScale;
    pText.text = Math.floor(xmlScale)+"%";
    if (xmlLoaded == xmlTotal) {
        trace(Math.floor(xmlScale)+" After Del");
        delete xmlPreload.onEnterFrame;
        gotoAndPlay(2);
    }
}

Then on Frame2 (where I want XML stuff to happen)


function loadXML(loaded) {
    if (loaded) {
        myXML = this.firstChild;
        myXMLLength = myXML.childNodes.length;
        for (var i = 0; i < myXMLLength; i++) {
            if (myXML.childNodes*.attributes.feature == feature_name) {
                _root.technology = myXML.childNodes*.childNodes[0].firstChild;
                _root.overview = myXML.childNodes*.childNodes[1].firstChild;
                //trace(myXML.childNodes*.attributes.webaddress);
                //trace(myXML.childNodes*.attributes.image);
                _root.image = myXML.childNodes*.attributes.image;
                break;
            }
        }
        technology_txt.text = _root.technology;
        overview_txt.text = _root.overview;
    } else {
        technology_txt.text = "Error Loading XML";
    }
}

Now if I preview the menu, it works - But if I preview that again (so it simulates a internet connection) the XML doesn’t get loaded before it uses the data from it.