okay - what about this one?

here is my script

// ActionScript Document

XML.prototype.ignoreWhite = true;
menuItems_array = [];

//function to load the Menu Items
function loadMenu(XMLDoc) {
        
        //set default paths
        var textFilesPath = "./updateable_files/";
        var sectionImagesPath = "./images/sectionimages/";
        
        //get content
        XMLVars = new XML();
        XMLVars.onLoad = function(success) {
                if (success) {
                        trace("success");
                        _root.description.htmlText = "<b>Loading 
content...</b>";
                                                
                        for (var i=0;i<this.firstChild.childNodes.length;i++) {
                                //set variables from XML
                                var thisKind = 
this.firstChild.childNodes[i].attributes.kind;
var thisText = this.firstChild.childNodes[i].childNodes [0].childNodes[0].nodeValue; var thisDescription = this.firstChild.childNodes[i].childNodes [1].childNodes[0].nodeValue; var thisSectionImage = this.firstChild.childNodes[i].childNodes [2].childNodes[0].nodeValue;
                                
                                //object to store starting attributes for 
menuItem
                                var tempObject = new Object();
                                tempObject.menuItem_txt = thisText;
                                tempObject.description = textFilesPath + 
thisDescription;
                                tempObject.description_txt = "copy to be 
replaced";
                                tempObject.sectionImage = sectionImagesPath + 
thisSectionImage;
                                tempObject._y = 13 * i;
                                _root.menu.attachMovie("menuItem_clip", 
thisKind, i, tempObject);
                                
                                //add item name to array
                                _root.menuItems_array.push(thisKind);
                        }
                        trace (_root.menuItems_array);
                } else {
                        _root.description.htmlText = "<b>Error loading 
menu</b>";
                }
        }
        XMLVars.load(textFilesPath+XMLDoc);
        trace(textFilesPath+XMLDoc);
}

//function to load the description_txt files in
function loadDescriptions() {
        trace (_root.menuItems_array.length);
        for (var i=0; i<_root.menuItems_array.length;i++) {
                trace (i);
        }
}

and i call the functions like this

loadMenu("menu.xml");
loadDescriptions();

but when i run this it runs in a really wierd order:

./updateable_files/ menu.xml ---->trace after XMLVars.load in loadMenu() 0 ---->trace in loadDescriptions() success ---->trace in loadMenu() -> XMLVars.onLoad news,about,how,projects,contact,vacancies,login ---->trace after for loop in loadMenu()

so even though the loadMenu() runs first, loadDescriptions() still runs before the XMLVars.load within loadMenu() ? is there a way i can force the whole of loadMenu() to run before loadDescriptions ?

alz _______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to