i'm remodeling a website i've done (www.mcoart.com). i want to exchange
information between XML and Flash files. i almost did it, but where shoul
display information about one item, the whole content of this 'field' is shown.
i'll explain better. this swf displays works of an artist. but the field 'date'
(or any other text field) display the content of all works (separated by
commas). i'll post the xml code and the actionscript code.
thanks
ed
0zeros - 17 Jan 2008 19:28 GMT
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>http://www.mcoart.com/_sitexml/arsi/oscinco.jpg</image>
<caption>ARLINDO SILVA</caption>
<caption>OS CINCO</caption>
<caption>2006</caption>
<caption>?LEO SOBRE TELA</caption>
<caption>26 x 14 cm.</caption>
</pic>
<pic>
<image>http://www.mcoart.com/_sitexml/arsi/demimparati.jpg</image>
<caption>ARLINDO SILVA</caption>
<caption>DE MIM PARA TI</caption>
<caption>2006</caption>
<caption>?LEO SOBRE TELA</caption>
<caption>26 x 14 cm.</caption>
</pic>
<pic>
<image>http://www.mcoart.com/_sitexml/arsi/aqueda.jpg</image>
<caption>ARLINDO SILVA</caption>
<caption>A QUEDA</caption>
<caption>2006</caption>
<caption>?LEO SOBRE TELA</caption>
<caption>26 x 14 cm.</caption>
</pic>
<pic>
<image>http://www.mcoart.com/_sitexml/arsi/oskar.jpg</image>
<caption>ARLINDO SILVA</caption>
<caption>OSKAR</caption>
<caption>2006</caption>
<caption>?LEO SOBRE TELA</caption>
<caption>26 x 14 cm.</caption>
</pic>
</images>
0zeros - 17 Jan 2008 19:29 GMT
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
artista = [];
trabalho = [];
ano = [];
tecnica = [];
dimensoes = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
artista[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
trabalho[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
ano[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
tecnica[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
dimensoes[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
artista.text = artista[p];
trabalho.text = trabalho[p];
ano.text = ano[p];
tecnica.text = tecnica[p];
dimensoes.text = dimensoes[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
artista.text = artista[p];
trabalho.text = trabalho[p];
ano.text = ano[p];
tecnica.text = tecnica[p];
dimensoes.text = dimensoes[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
artista.text = artista[p];
trabalho.text = trabalho[p];
ano.text = ano[p];
tecnica.text = tecnica[p];
dimensoes.text = dimensoes[p];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}