I’m trying to generate a random background and css file using an xml document. My xml structure is as such:
<?xml version="1.0" encoding="iso-8859-1"?>
<backgrounds>
<pic>
<image>http://www.21bluefish.com/images/21bluefish_logo5.jpg</image>
<name>Logo 5</name>
<location>My Computer</location>
</pic>
<pic>
<image>http://www.21bluefish.com/images/Me_coat_small.jpg</image>
<name>Me coat small</name>
<location>Calumet City, IL</location>
</pic>
</backgrounds>
It’s pretty standard.
What I’ve got so far as far as code is this:
backgrounds = new Array("0.jpg", "1.jpg", "2.jpg", "3.jpg");
function randomBackground(){
randomNumber = random (backgrounds.length);
loadMovie (backgrounds[randomNumber], "_root.background");
}
randomBackground();
var format = new TextField.StyleSheet();
var path = "http://www.21bluefish.com/" + randomNumber + ".css";
format.load(path);
format.onLoad = function(loaded) {
if (loaded) {
output.styleSheet = format;
myLoadVar = new LoadVars ();
myLoadVar.load("john.txt")
myLoadVar.onLoad = function (success){
if (success == true) {
output.variable = "john"
output.htmlText=myLoadVar.kirupa;
}
}
} else {
output.text = "Error loading CSS file!";
}
};
The problem is, I don’t want to use an array like I have it right now, because then updating it is a pain. What I want to do is retrieve the xml file, count the pic element and take that number and put it into a variable to multiply it by random. I then want to display the background file in an empty mc, as well as retrieve the name and location elements and display them in a text box. D**n this sounds complicated now. Well, I’m stumped so any help or a kick or push in the right position would be wonderful. Thanks.