Click to See Complete Forum and Search --> : Flash xml slideshow


dcs
08-29-2008, 06:52 AM
Hi.. im having a lil problem in actionScript of flash.

this is the xml code

<xml>
<images>
<image title="1">img/slide/01.jpg</image>
<image title="2">img/slide/02.jpg</image>
<image title="3">img/slide/03.jpg</image>
<image title="4">img/slide/04.jpg</image>
</images>
</xml>


Flash ActionScript

currentframe = mc._currentframe;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");


function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].firstChild.nodeValue;
}
randomImage();
}
}

function randomImage() {
if (loaded == filesize) {
var ran = Math.round(Math.random() * (totalImages - 1));
picture_mc.loadMovie(imageFileName[ran], 1);
pause();
}
}

function pause() {
if (currentframe == 1) {
randomImage();
}
}


I dont know why this dsnt work.

if i change the xml file as follows

<xml>
<images>
<image title="img/slide/01.jpg">img/slide/01.jpg</image>
<image title="img/slide/02.jpg">img/slide/02.jpg</image>
<image title="img/slide/03.jpg">img/slide/03.jpg</image>
<image title="img/slide/04.jpg">img/slide/04.jpg</image>
</images>
</xml>


and action script:
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].firstChild.nodeValue;

to

imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;

it works.

pls help

Eye for Video
08-29-2008, 11:40 PM
Not really sure why it doesn't work for you. I tried both but used one less folder depth (just because I didn't have it) and got them both to work. Hummm...
<xml>
<images>
<image title="1">images/img001.jpg</image>
<image title="2">images/img002.jpg</image>
<image title="3">images/img003.jpg</image>
<image title="4">images/img004.jpg</image>
</images>
</xml>Could it be something in the creation of the xml file, an invisible character or something?
Good luck,
Eye for Video
www.cidigitalmedia.com