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);
};