Need help tweaking actionscript
I'm trying to create a flash movie that will act as a "player" for a series of external SWF files that are listed by an external XML file.
Someone was able to pass on the following XML:
Quote:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node swf='1.swf' />
<node swf='2.swf' />
<node swf='3.swf' />
<node swf='4.swf' />
<node swf='5.swf' />
</root>
and the following actionscript (to be dropped into the first frame of the "player" SWF:
Quote:
swfArray = new Array();
/* load the xml file into your shell */
var _xml = new XML();
_xml.ignoreWhite = true;
_xml.load("test.xml");
/* parse and add the contents to an array */
_xml.onLoad = function(){
var cNodes = this.firstChild.childNodes;
var len = cNodes.length
for (var i=0; i!=len; i++) {
swfArray[i] = cNodes[i].attributes.swf;
}
/* loading a random file? shuffle the array */
trace("Before shuffling - "+swfArray);
swfArray.sort(function(){return Math.floor(Math.random()*3)-1});
trace("After shuffling - "+swfArray);
/* remove the last element from the array */
swfToPlay = swfArray.pop();
/* use the MovieClipLoader class to load the file */
mcLoader.loadClip(swfToPlay, container);
};
var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
/* alter any of the properties of the loaded file here */
function onLoadInit(mc:MovieClip) {
trace(swfToPlay+" loaded to "+ mc);
};
However, the above plays the SWFs in a random sequence, rather than sequentially.
Any assistance in changing this to sequential play would be greatly appreciated.
-thanks!