hi, i'm new to flash - xml integration. i have almost everything solved.
however, there's a few fields on xml that don't have information. i knew that
it would give me the message 'undefined', so i inserted a blank space in the
xml file, but it continues to display 'undefined'!!! how can i solve this?
[djdomain] - 28 Jan 2008 21:32 GMT
Can you post your code please
0zeros - 29 Jan 2008 06:03 GMT
hi! here's the xml code (it's of course partial). note that the field
'coleccao' is empty:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<imagem>http://www.mcoart.com/site2008/arsi/oscinco.jpg</imagem>
<artista1>ARLINDO</artista1>
<artista2>SILVA</artista2>
<trabalho>OS CINCO</trabalho>
<ano>2006</ano>
<tecnica>ÓLEO SOBRE TELA</tecnica>
<dimensoes>33 x 44 cm.</dimensoes>
<coleccao></coleccao>
</pic>
</images>
0zeros - 29 Jan 2008 06:07 GMT
and here's the actionscript code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
imagem = [];
artista1 = [];
artista2 = [];
trabalho = [];
ano = [];
tecnica = [];
dimensoes = [];
coleccao = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
imagem[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
artista1[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
artista2[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
trabalho[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
ano[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
tecnica[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
dimensoes[i] = xmlNode.childNodes[i].childNodes[6].firstChild.nodeValue;
coleccao[i] = xmlNode.childNodes[i].childNodes[7].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("imagens.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(imagem[p],1);
desc_txt.text = artista1[p];
desc_txt1.text = artista2[p];
desc_txt2.text = trabalho[p];
desc_txt3.text = ano[p];
desc_txt4.text = tecnica[p];
desc_txt5.text = dimensoes[p];
desc_txt6.text = coleccao[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(imagem[p],1);
desc_txt.text = artista1[p];
desc_txt1.text = artista2[p];
desc_txt2.text = trabalho[p];
desc_txt3.text = ano[p];
desc_txt4.text = tecnica[p];
desc_txt5.text = dimensoes[p];
desc_txt6.text = coleccao[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(imagem[0],1);
desc_txt.text = artista1[p];
desc_txt1.text = artista2[p];
desc_txt2.text = trabalho[p];
desc_txt3.text = ano[p];
desc_txt4.text = tecnica[p];
desc_txt5.text = dimensoes[p];
desc_txt6.text = coleccao[p];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}