Tengo un flash que me lee un xml.. Todo perfecto al leer, pero quisiera saber si existe una manera que me lea de abajo hacia arriba y no arriba hacia abajo..
Este es el codigo action script
Código:
stop();//Permite caracteres tradicionales como letras con tilde la ñ, etc.
System.useCodepage = true;
//Se declara la variable indice de tipo número (utilizada para referencia la noticia a mostrar)
var indice:Number;
//Se declara la variable noticias_xml de tipo XML (utilizada para almacenar el documento xml)
var noticias_xml:XML;
/*
Funcion cargarDatos (utilizada para cargar y cambiar las noticias en el documento)
Esta función recibe un parámetro "_indice" que corresponde al elemento noticia a mostrar
*/
function cargarDatos(_indice:Number){
//Se inicializan variables utilizadas para almenar los datos de una noticia
var fecha1:String;
var fecha2:String;
var fecha3:String;
var mensaje1:String;
var mensaje2:String;
var mensaje3:String;
var flyer1:String;
var flyer2:String;
var flyer3:String;
//Se accede al primer hijo de elemento [noticia] y se recupera al valor del primer elemento de [titulo]
fecha1 = noticias_xml.firstChild.childNodes[0].firstChild.firstChild.nodeValue;
//Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
mensaje1 = noticias_xml.firstChild.childNodes[0].firstChild.nextSibling.firstChild.nodeValue
fecha2 = noticias_xml.firstChild.childNodes[1].firstChild.firstChild.nodeValue;
//Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
mensaje2 = noticias_xml.firstChild.childNodes[1].firstChild.nextSibling.firstChild.nodeValue
fecha3 = noticias_xml.firstChild.childNodes[2].firstChild.firstChild.nodeValue;
//Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
mensaje3 = noticias_xml.firstChild.childNodes[2].firstChild.nextSibling.firstChild.nodeValue
//Se accede al último hijo de elemento [noticia] y se recupera el valor del primer elemento de [imagen]
flyer1 = noticias_xml.firstChild.childNodes[0].lastChild.firstChild.nodeValue
flyer2 = noticias_xml.firstChild.childNodes[1].lastChild.firstChild.nodeValue
flyer3 = noticias_xml.firstChild.childNodes[2].lastChild.firstChild.nodeValue
//Mostrando los datos recuperados en el cuado de texto mensaje_txt y cargando la imagen en pantalla_mc
_root.fecha1.htmlText = "";
_root.fecha1.htmlText += "<b>" + fecha1 + "</b></font></p>";
_root.mensaje1.htmlText += "<b>" + mensaje1 + "</b></font>";
_root.fecha2.htmlText = "";
_root.fecha2.htmlText += "<b>" + fecha2 + "</b></font></p>";
_root.mensaje2.htmlText += "<b>" + mensaje2 + "</b></font>";
_root.fecha3.htmlText = "";
_root.fecha3.htmlText += "<b>" + fecha3 + "</b></font></p>";
_root.mensaje3.htmlText += "<b>" + mensaje3 + "</b></font>";
_root.flyer1.loadMovie(flyer1);
_root.flyer2.loadMovie(flyer2);
_root.flyer3.loadMovie(flyer3);
//Cargado la imagen JPG externa en el clip pantalla_mc con el valor recuperado del objeto xml
}
//Función que permite avanzar a la [noticia] siguiente almacenada en el objeto xml
siguiente_btn.onPress = function(){
//comprobando si existe el siguiente elemento [noticia]
if(noticias_xml.firstChild.childNodes[indice+1] != null){//retringue a avanzar solo si hay una [noticia] siguiente
indice++; //incrementado en uno el indice
cargarDatos(indice); //recuprando y mostrando los datos y la imagen en la pantalla
}
}
//Función que permite retroceder a la noticia anterior almacenada en el objeto xml
anterior_btn.onPress = function(){
//comprobando si existe una elemento [noticia] anterior
if(noticias_xml.firstChild.childNodes[indice-1] != null){//retringue a avanzar solo si hay una [noticia] anterior
indice--; //reducciendo en uno el indice
cargarDatos(indice); //recuprando y mostrando los datos y la imagen en la pantalla
}
}
//Inicializaciones
indice=0; //inicializando indice en 0 para mostrar la primera noticia
//creando el objeto noticias_xml de typo XML
noticias_xml = new XML();
//Permite que el objeto XML ignore los espacios en blanco entre marca y marca del documento XML
noticias_xml.ignoreWhite = true;
//El método load() permite cargar el documento xml "noticias.xml"
noticias_xml.load("noticias.xml");
//El evento onLoad de activa cuado se haya cargado el documento noticias.xml
noticias_xml.onLoad = function(){
//Se llama a la funcion cragarDatos para mostar la primera noticia (esto por la variable indice en 0)
cargarDatos(indice);
}


