Comunidad de diseño web y desarrollo en internet online

pregunta acerca de carga de un xml

Citar            
MensajeEscrito el 19 Ene 2009 02:36 pm
Hola a todos, tengo una duda acerca de como cargar un nuevo dato de un xml, de donde cargo un thumb y una foto grande; que ya me esta funcionando, pero quiero agregar un valor mas, un nombre para el thumbnail pero se me esta complicando

el codigo del flash es:

Código :

var prof:Number = 0;
createEmptyMovieClip("noticias", prof++);
noticias._x = 0;
noticias._y = 0;

function carga_XML() {
   menu = new XML();
   menu.load("listado.xml");
   menu.referencia = this;
   menu.onLoad = interprete;
   menu.ignoreWhite = true;
}

function interprete() {
   menuArray = menu.firstChild.childNodes;
   var y:Number = 0;//posicion del mc contenedor y
   var x:Number = 100;// pos x de los thumbs
   var i:Number = 0;
   for (i=0; i<6; i++) {
      noticias.attachMovie("clip", "clip"+i, prof++, {_x:x*i, _y:y, foto:menuArray[i].attributes.Foto, grande:menuArray[i].attributes.GRANDE}); // hace las x primera fila
      noticias.attachMovie("clip", "clip2"+i, prof++, {_x:x*i, _y:(y*i)+82, foto:menuArray[i+6].attributes.Foto, grande:menuArray[i].attributes.GRANDE}); //2ª fila
      noticias.attachMovie("clip", "clip3"+i, prof++, {_x:x*i, _y:(y*i)+164, foto:menuArray[i+12].attributes.Foto, grande:menuArray[i].attributes.GRANDE});// 3ª
      //noticias.attachMovie("clip", "clip4"+i, prof++, {_x:(x*i), _y:(y*i)+300, foto:menuArray[i+6].attributes.Foto});//4ª
   }
}
carga_XML();


y el xml:

Código :


<?xml version="1.0" encoding="utf-8" ?>
<noticias>
<noti Foto="lentes_ch/1.jpg" GRANDE="lentes_gr/1.png"/>
<noti Foto="lentes_ch/2.jpg" GRANDE="lentes_gr/2.png"/>
<noti Foto="lentes_ch/3.jpg" GRANDE="lentes_gr/1.png" />
<noti Foto="lentes_ch/4.jpg" GRANDE="lentes_gr/1.png" />
<noti Foto="lentes_ch/5.jpg" GRANDE="lentes_gr/1.png" />

</noticias>



les agradezco muchisimo la ayuda que me puedan dar


Saludos

Por ANDRESCABEZA

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Ene 2009 04:04 pm
Agrega el atributo en el nodo noti de tu XML y luego lo muestras en algun lado de flash, el aprseo es muy similar al que tienes:

menuArray = menu.firstChild.childNodes;
La primera foto es menuArray[0].attributes.GRANDE
Si tu nuevo atributo se llama TEXTO, sería

menuArray[0].attributes.TEXTO

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 20 Ene 2009 12:50 pm
Muchas Gracias Jorge, pero sabes que le estoy errando en algo, capaz que es una estupidez, soy un rookie y la necesidad me hace darme de nariz contra esto, es divertido pero algo estressante :)

lo primero es que puse la llamada al elemento TEXTO desde el action y al parecer no me dio problemas, quedo así:

Código :

var prof:Number = 0;
createEmptyMovieClip("noticias", prof++);
noticias._x = 0;
noticias._y = 0;

function carga_XML() {
   menu = new XML();
   menu.load("listado.xml");
   menu.referencia = this;
   menu.onLoad = interprete;
   menu.ignoreWhite = true;
}

function interprete() {
   menuArray = menu.firstChild.childNodes;
   var y:Number = 0;//posicion del mc contenedor y
   var x:Number = 100;// pos x de los thumbs
   var i:Number = 0;
   for (i=0; i<6; i++) {
      noticias.attachMovie("clip", "clip"+i, prof++, {_x:x*i, _y:y, foto:menuArray[i].attributes.Foto, grande:menuArray[i].attributes.GRANDE}, menuArray[0].attributes.TEXTO); // hace las x primera fila
      noticias.attachMovie("clip", "clip2"+i, prof++, {_x:x*i, _y:(y*i)+82, foto:menuArray[i+6].attributes.Foto, grande:menuArray[i].attributes.GRANDE}); //2ª fila
      noticias.attachMovie("clip", "clip3"+i, prof++, {_x:x*i, _y:(y*i)+164, foto:menuArray[i+12].attributes.Foto, grande:menuArray[i].attributes.GRANDE});// 3ª
      //noticias.attachMovie("clip", "clip4"+i, prof++, {_x:(x*i), _y:(y*i)+300, foto:menuArray[i+6].attributes.Foto});//4ª
   }
}
carga_XML();


al xml le agregue el valor:

Código :


<noticias>
<noti Foto="lentes_ch/1.jpg" GRANDE="lentes_gr/1.png" TEXTO="nombre del item"/>
<noti Foto="lentes_ch/2.jpg" GRANDE="lentes_gr/2.png"/>
<noti Foto="lentes_ch/3.jpg" GRANDE="lentes_gr/1.png" />
<noti Foto="lentes_ch/4.jpg" GRANDE="lentes_gr/1.png" />

</noticias>



y por ultimo puse un texto dinamico con TEXTO como nombre de instancia, pero no lo estoy viendo aun, algo estoy haciendo mal, porque aparte necesito que el nombre del thumb se repita en cada uno de ellos y no creo q asi lo logre

vuelvo a agradecer tu interes

Saludos

Por ANDRESCABEZA

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Ene 2009 01:03 pm
Sería:

Código ActionScript :

tit = noticias.attachMovie("clip", "clip"+i, prof++, {_x:x*i, _y:y, foto:menuArray[i].attributes.Foto, grande:menuArray[i].attributes.GRANDE}); // hace las x primera fila
tit.TEXTO.text = menuArray[0].attributes.TEXTO


Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 20 Ene 2009 01:40 pm
bueno mejoró, pero en el texto dinamico me aparece "_level0.instance2.TEXTO" en vez de aparecerme la info del xml, y me aparece una vez sola en lugar de aparecerme varias veces en los thumbs cargados

Por ANDRESCABEZA

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Ene 2009 01:42 pm
Es menuArray[i].attributes.TEXTO , trázalo en el loop a ver que sale

trace(menuArray[i].attributes.TEXTO )

Of course estoy hablando de nombre de instancia del campo de texto, no de variable asociada

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 20 Ene 2009 01:50 pm
Me sale "undefined" y si tenia TEXTO como nombre de instancia del campo de texto y tambien como variable asociada, ya se lo saque como variable

Por ANDRESCABEZA

13 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Ene 2009 04:13 pm
Si trazas

menuArray[i].attributes.GRANDE

y te sale el valor y trazas

menuArray[i].attributes.TEXTO

Y sale undefined, entonces falta el atributo TEXTO en ese nodo del XML

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 23 Ene 2009 06:05 pm
Jorge me sale undefined cuando hago el trace en los 2.. es raro..

Por ANDRESCABEZA

13 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.