Estoy procesando un XML, todo va bien , vuelco los datos a un array o arrays , mientras se procesa el volcado del XML, puedo meter el resultado de los arrays en cajas de texto etc.....
Todo esto se hace dentro de una funcion , el problema viene cuando quiero utilizar ese array fuera de la funcion, me dice que "undefined", es como si perdiera los valores, tiene esto algo que ver con los niveles??
Muestro el codigo:
function cargaxmlpagina() {
var xmlfile = new XML();
xmlfile.ignoreWhite = true;
xmlfile.onLoad = function(success) {
//valores.text = "";
if (success) {
root_tag = this.firstChild;
totalsub = root_tag.childNodes;
//id = root_tag.attributes.id;
_level0.cadtexto_def = new Array();
var _l1 = 0;
while (_l1<totalsub.length) {
_level0.cadtexto_def[_l1] = new Array();
//_level0.cadtexto_def[_l1].orden = root_tag.childNodes[_l1].attributes.orden;
_level0.cadtexto_def[_l1].txt = root_tag.childNodes[_l1].attributes.txt;
caja1.text += _level0.cadtexto_def[_l1].txt+"\n\n";
caja1.setTextFormat(miFormato);
//valores.text +=totalsub.length+"\n"+_l1 ;
_l1++;
}
// end while
}
// end if
}
//xmlfile.load(id_page+".xml");
xmlfile.load("1.xml");
}
var capas = createEmptyMovieClip("fondo", 1);
this.createTextField("caja1", 2, 5, 0, 400, Stage.height-10);
caja1.multiline = true;
caja1.wordWrap = true;
caja1.border = true;
miFormato = new TextFormat();
miFormato.leading = 0;
miFormato.font = "Tahoma";
miFormato.size = 13;
miFormato.color = 0xffffff;
//var contenido = "SEGUIMOS HACIENDO PRUEBAS CON EL FLASH DINAMICO, LA VERDAD ES QUE ES BASTANTE ENTRETENIDO";
cargaxmlpagina();
caja1.text += _root.cadtexto_def[0].txt+"\n";
//valores.text += "hola\n";
caja1.setTextFormat(miFormato);
capas._x = Stage.width/2;
capas._y = 0;
capas = fondo.loadMovie("01.jpg", 2);
El problema viene al hacer referencia directa a un elemento del array : _root.cadtexto_def[0].txt, y volcarlo en una caja de texto, no tienen valor los elementos del array.
gracias de antemano.