Ciao a tutti,

leggo un file xml, quindi faccio un ciclo.
il risultato e uno e lo devo assegnare ad una variabile, della quale poi faccio il return.

Ma ad un certo punto me la trovo undefine e non capisco perchè....
Io ho bisogno che nel return ci sia il valore della variabile... come posso fare?? dove sbaglio?

Codice PHP:
_global.Eti = function(id:String):String {    
    var 
strEti:String
    
try {
        var 
xml_resourceSwf = new XML();
        
resourceSwf = new Array();
        
xml_resourceSwf.load ("resourceSwf.en.xml"); 
        
xml_resourceSwf.onLoad=function(success) {
            if (
xml_resourceSwf.loaded) {
                
resourceSwf xml_resourceSwf.firstChild.childNodes;
                for (
l:Number=0;l<=resourceSwf.length-1;l++){        
                    if (
resourceSwf[l].attributes.id == id){
                        
strEti=String(resourceSwf[l].attributes.txt);            
                    }
                }
            }
        
trace("****************QUI LEGGO" strEti)
        }
        
trace("****************QUI è UNDEFINED!!!" strEti)
    }
    catch(
err) {
        
trace("Eti: xml failed!\n"+err)
    }
    return 
strEti