Foros del Web » Creando para Internet » Flash y Actionscript »

Ayuda.. lector de xml problemita

Estas en el tema de Ayuda.. lector de xml problemita en el foro de Flash y Actionscript en Foros del Web. Hola necesito una manito por favor.. Tengo un flash que me lee un xml.. Todo perfecto al leer, pero quisiera saber si existe una manera ...
  #1 (permalink)  
Antiguo 05/08/2010, 10:52
 
Fecha de Ingreso: septiembre-2005
Mensajes: 11
Antigüedad: 18 años, 7 meses
Puntos: 0
Ayuda.. lector de xml problemita

Hola necesito una manito por favor..
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);			
	}
  #2 (permalink)  
Antiguo 06/08/2010, 20:18
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Ayuda.. lector de xml problemita

hola
no entiendo bien lo que pretendes, será cambiar el orden de los datos que vienen del xml?
has intentado esto?

Código actionscript:
Ver original
  1. fecha1 = noticias_xml.firstChild.childNodes[2].firstChild.firstChild.nodeValue;
  2.             //Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
  3.         mensaje1 = noticias_xml.firstChild.childNodes[2].firstChild.nextSibling.firstChild.nodeValue
  4.         fecha2 = noticias_xml.firstChild.childNodes[1].firstChild.firstChild.nodeValue;
  5.             //Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
  6.         mensaje2 = noticias_xml.firstChild.childNodes[1].firstChild.nextSibling.firstChild.nodeValue
  7.         fecha3 = noticias_xml.firstChild.childNodes[0].firstChild.firstChild.nodeValue;
  8.             //Se accede al segundo hijo de elemento [noticia] y se recupera el valor del primer elemento de [mensaje]
  9.         mensaje3 = noticias_xml.firstChild.childNodes[0].firstChild.nextSibling.firstChild.nodeValue
  10.                 //Se accede al último hijo de elemento [noticia] y se recupera el valor del primer elemento de [imagen]
  11.         flyer1 = noticias_xml.firstChild.childNodes[2].lastChild.firstChild.nodeValue
  12.         flyer2 = noticias_xml.firstChild.childNodes[1].lastChild.firstChild.nodeValue
  13.         flyer3 = noticias_xml.firstChild.childNodes[0].lastChild.firstChild.nodeValue

comentas
saludos
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com

Etiquetas: abajo, arriba, xml
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:28.