flash actionscript:
I am very new to doing ActionScripts and I want to create an applet which reads
from an XML and builds an array of the URL for images, then loads the images in
a repeat with about 5 second intervals without the use of any buttons. Here's
what I have in my actionscript coding, but what does not seem to work is the
ability to switch images in a loop. How can I do that?
ap_xml = new XML();
ap_xml.ignoreWhite = true;
ap_xml.load('imglist.xml');
ap_xml.onLoad = function(success) {
if (success) {
xml2Array(this);
}
};
function xml2Array(filexml):Boolean {
var aImgFiles:Array = new Array();
aImgFiles = parseFile(filexml);
aImgFiles = myScramble(aImgFiles);
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
var mc:MovieClip = this.createEmptyMovieClip("mc",
this.getNextHighestDepth());
for (j = 0; j < 5; j++) {
mcLoader.loadClip(aImgFiles[(j % aImgFiles.length)], mc);
}
return true;
}
function parseFile(xmlDoc_xml):Array {
var temp = new Array();
for (var a = 0; a<xmlDoc_xml.firstChild.childNodes.length; a++) {
temp.push(xmlDoc_xml.firstChild.childNodes[a].firstChild.nodeValue);
}
return temp;
}
function myScramble(fArray:Array):Array {
var tmpArray = new Array();
for(var i = fArray.length; i > 0; i--) {
var j = Math.random() * i;
j = Math.floor(j);
tmpArray.push(fArray[j]);
fArray.splice(j,1);
}
return tmpArray;
}