Comunidad de diseño web y desarrollo en internet online

Ayuda con el ejemplo (Flash+XML)

Citar            
MensajeEscrito el 13 Mar 2006 05:42 pm
COMO PONER UNA IMAGE EN CADA 'LIBRO'?

XML:

Código :

<DOCUMENTO>
   <LIBRO ID="0001">
       <TITULO>El Hobbit</TITULO>
       <AUTOR>J.R.R. Tolkien</AUTOR>
       <EDITORIAL>Anaya</EDITORIAL>
      <WEB URL="http://www.elhobbit.com">elhobbit.com</WEB>
   </LIBRO>

   <LIBRO ID="0002">
       <TITULO>La Fundacion</TITULO>
       <AUTOR>Isaac Asimov</AUTOR>
       <EDITORIAL>RBA</EDITORIAL>
      <WEB URL="http://www.thefoundation.com">thefoundation.com</WEB>
   </LIBRO>

   <LIBRO ID="0003">
       <TITULO>El Caballo de Troya</TITULO>
       <AUTOR>J.J. Benitez</AUTOR>
       <EDITORIAL>CIFI</EDITORIAL>
      <WEB URL="http://www.elcaballodetroya.com">elcaballodetroya.com</WEB>
   </LIBRO>

   <LIBRO ID="0004">
       <TITULO>1984</TITULO>
       <AUTOR>George Orwell</AUTOR>
       <EDITORIAL>Raven</EDITORIAL>
      <WEB URL="http://www.georgeorwell.com">georgeorwell.com</WEB>
   </LIBRO>
</DOCUMENTO>


ACTION EN FLASH:

Código :

miXML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(leido) {
    if (leido) {
        i = 0;
        testXML();
    } else {
        trace("No se puede leer el XML");
    }
};
miXML.load("libros.xml");
function testXML() {
    documento = miXML.firstChild;
    libro = miXML.firstChild.childNodes[i];
    ref_txt = libro.attributes.ID;
    tit_txt = libro.childNodes[0].firstChild;
    aut_txt = libro.childNodes[1].firstChild;
    edi_txt = libro.childNodes[2].firstChild;
    url_txt = "<a href=\""+libro.childNodes[3].attributes.URL+"\" target=\"_blank\">"+libro.childNodes[3].firstChild+"</href>";
}
primens.onPress = function() {
    i = 0;
    testXML();
};
ultim.onPress = function() {
    i = documento.childNodes.length-1;
    testXML();
};
libroadelante.onPress = function() {
    if (i<documento.childNodes.length-1) {
        i++;
    } else {
        i = 0;
    }
    testXML();
};
libroatras.onPress = function() {
    if (i>0) {
        i--;
    } else {
        i = documento.childNodes.length-1;
    }
    testXML();
};
[/code]

Por Kel Teixeira

7 de clabLevel



 

Brasil

msie
Citar            
MensajeEscrito el 15 Mar 2006 04:20 pm
nadie! :crap:

Por Kel Teixeira

7 de clabLevel



 

Brasil

msie
Citar            
MensajeEscrito el 15 Mar 2006 04:29 pm
Emmm, a que te refieres???

Si quieres decir, como ampliar el XML para referenciar a una imagen por libro, pues... create un TAG <IMAGEN>foto.jpg</IMAGEN> por cada nodo <LIBRO>.

En cuanto a la recuperación de ese dato pues:

Código :

function testXML() {
    documento = miXML.firstChild;
    libro = miXML.firstChild.childNodes[i];
    ref_txt = libro.attributes.ID;
    tit_txt = libro.childNodes[0].firstChild;
    aut_txt = libro.childNodes[1].firstChild;
    edi_txt = libro.childNodes[2].firstChild;
    url_txt = "<a href=\""+libro.childNodes[3].attributes.URL+"\" target=\"_blank\">"+libro.childNodes[3].firstChild+"</href>";
    img_txt = libro.childNodes[4].firstChild;
}


Prueba y nos comentas :)

Por MorphX

SWAT Team

982 de clabLevel

3 tutoriales

  SWAT

La Telaraña Digital

clabbrowser
Citar            
MensajeEscrito el 15 Mar 2006 09:34 pm
me gustaria que la imagen se cargasse en un MovieClip!
con la action loadMovie. pero no sé como!

Por Kel Teixeira

7 de clabLevel



 

Brasil

msie
Citar            
MensajeEscrito el 15 Mar 2006 09:55 pm
admeás de lo que te dijo MorphX


Creá un movieclip donde vas a cargar la imágen, pongamos img_mc y le agregás a tu función textXML

Código :

function testXML() {
    documento = miXML.firstChild;
    libro = miXML.firstChild.childNodes[i];
    ref_txt = libro.attributes.ID;
    tit_txt = libro.childNodes[0].firstChild;
    aut_txt = libro.childNodes[1].firstChild;
    edi_txt = libro.childNodes[2].firstChild;
    url_txt = "<a href=\""+libro.childNodes[3].attributes.URL+"\" target=\"_blank\">"+libro.childNodes[3].firstChild+"</href>";
    img_txt = libro.childNodes[4].firstChild;
    img_mc.loadMovie(img_txt,profundidad)
 }


Con eso tiene que andar

Por el_itur

142 de clabLevel



Genero:Masculino  

Argentina

firefox
Citar            
MensajeEscrito el 15 Mar 2006 11:54 pm

Por Kel Teixeira

7 de clabLevel



 

Brasil

msie
Citar            
MensajeEscrito el 23 Mar 2006 10:05 am
Solamente decir que me ha ayudado mucho este post para "entrar" un poco más en el mundo xml-flash.

Gracias.

Por One

Claber

1488 de clabLevel

5 tutoriales

Genero:Masculino  

Programador Web

firefox

 

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