Need help making XML.onLoad return a value

After using Google and these forums I’ve discovered that it’s not possible to return a value directly from this function. However, I still need some kind of workaround, so here is my scenario:

This function overrides the default onLoad function when I load up my XML. It works perfectly.


xmlContent.onLoad = function (success) {  
        
        if (success) {
                //trace("XML Fetch Success");
                xmlContent = xmlContent.firstChild.firstChild.firstChild;
                                
                for (x in xmlContent.childNodes)
                {                    
                    if (xmlContent.childNodes[x].nodeName == "Content")
                    {                        
                        sContent = xmlContent.childNodes[x].firstChild;
                    }
                }                
        }
        else
        {
            sContent = "Error";            
        }        
        
                
};

I want to somehow use this functionality to return the value of sContent when it is loaded, so I can use the line

returnContent(x)

in conjunction with the following function

function returnContent(Nume) {

    xmlContent.load(x);

}

to return a string from the xml on an on load event.

I.e. -

on mouseclick, a texfield.text variable is assigned to returnContent(x);

Thanks for any help that is to follow. This is extremely desperate for a project I’m working on :frowning: