Randomizing an XML Array

Hello all,

I’m having problems with the script below. Basically, it loads and parses an external XML file. I have it set to just step through the file but I’d like it to randomly display the images referenced by the XML. The script works like this, but I can’t seem to figure out how to get the XMl into an array and then have the function read it correctly. It seems to me that the call:

picture.loadMovie(image[p], 1);

with p being changed somehow to a call to myArray should work, but it doesn’t. What am I doing wrong?

////this creates the load XML function and counts the children to an array
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = “file not loaded!”;
}
}

////basic XML data stuff
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“images.xml”);

//////////////////file loader
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 firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}

function autoImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
setInterval(autoImage, 10000);

/////Array shuffle
Array.prototype.Shuffle = function() {
for (var j=this.length-1; j>0; j–) {
var pick = random(j);
var tmp = this[pick];
this[pick] = this[j];
this[j] = tmp;
}
};

///so the XML needs to loaded into the array somehow. Here’s the array with a bunch of numbers instead of the XML info.
myArray=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
myArray.Shuffle();