rispolvero questo 3d per ulteriori chiarimenti in merito
cmq sono riuscito nel mio intento ciè quello di prendere delle info da un file xml e metterle in un filmato flash modificando del codice
vista da un tutorial, in pratica ho una pag fla in cui ci sono
sei mc vuoti (fig1, fig2,...,fig6) e 6 caselle di testo dinamico così chiamate (testo,testo1,...,testo5)
adesso il codice che ho utilizzate per prendere le info dall'xml è il seguente
codice:
stop();
mio_xml = new XML();
mio_xml.path = this;
mio_xml.ignoreWhite = true;
mio_xml.onLoad = function(success)
{
if(success){
var t1 = "<font color='#376AE2'>";
var t2 = "</font>";
var u1 = "<font color='#FFCC00'>";
var u2 = "</font>";
var nodes = this.firstChild.childNodes;
this.path.titolo1 = "" + this.firstChild.attributes.genere + "";
for(var i = 0; i < 1; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo += "Art. " + (i + 1) + "
";
this.path.testo += "Modello: " + t1 + modello + t2 + "
";
this.path.testo += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo += "" + u1 + info + u2 +"";
fig1.loadMovie(foto);
}
for(var i = 1; i < 2; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo1 += "Art. " + (i + 1) + "
";
this.path.testo1 += "Modello: " + t1 + modello + t2 + "
";
this.path.testo1 += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo1 += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo1 += "" + u1 + info + u2 +"";
fig2.loadMovie(foto);
}
for(var i = 2; i < 3; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo2 += "Art. " + (i + 1) + "
";
this.path.testo2 += "Modello: " + t1 + modello + t2 + "
";
this.path.testo2 += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo2 += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo2 += "" + u1 + info + u2 +"";
fig3.loadMovie(foto);
}
for(var i = 3; i < 4; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo3 += "Art. " + (i + 1) + "
";
this.path.testo3 += "Modello: " + t1 + modello + t2 + "
";
this.path.testo3 += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo3 += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo3 += "" + u1 + info + u2 +"";
fig4.loadMovie(foto);
}
for(var i = 4; i < 5; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo4 += "Art. " + (i + 1) + "
";
this.path.testo4 += "Modello: " + t1 + modello + t2 + "
";
this.path.testo4 += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo4 += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo4 += "" + u1 + info + u2 +"";
fig5.loadMovie(foto);
}
for(var i = 5; i < 6; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo5 += "Art. " + (i + 1) + "
";
this.path.testo5 += "Modello: " + t1 + modello + t2 + "
";
this.path.testo5 += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo5 += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo5 += "" + u1 + info + u2 +"";
fig6.loadMovie(foto);
}
} else {
this.path.testo = "caricamento errato";
}
};
mio_xml.load("abbtennis.xml");
vorrei ottimizzare x prima cosa il codice in quanto ci sono sei cicli
for diciamo inutili quindi avevo pensato aggiustando x prima cosa i nomi delle caselle di testo cn testo1 ... testo6 e poi usare il seguente codice
codice:
stop();
mio_xml = new XML();
mio_xml.path = this;
mio_xml.ignoreWhite = true;
mio_xml.onLoad = function(success)
{
if(success){
var t1 = "<font color='#376AE2'>";
var t2 = "</font>";
var u1 = "<font color='#FFCC00'>";
var u2 = "</font>";
var nodes = this.firstChild.childNodes;
this.path.titolo1 = "" + this.firstChild.attributes.genere + "";
for(var i = 0; i < 5; i++){
var modello = nodes[i].attributes.modello;
var descrizione = nodes[i].attributes.descrizione;
var prezzo = nodes[i].attributes.prezzo;
var foto = nodes[i].attributes.foto;
var link = nodes[i].attributes.link;
var info = nodes[i].attributes.info;
this.path.testo[i] += "Art. " + (i + 1) + "
";
this.path.testo[i] += "Modello: " + t1 + modello + t2 + "
";
this.path.testo[i] += "Descrizione: " + t1 + descrizione + t2 + "
";
this.path.testo[i] += "Prezzo: €" + t1 + prezzo + t2 + "
";
this.path.testo[i] += "" + u1 + info + u2 +"";
fig[i].loadMovie(foto);
}
} else {
this.path.testo = "caricamento errato";
}
};
mio_xml.load("abbtennis.xml");
ma nn funziona sicuramente sbaglio qualcosa
grazie