Hi guys,
i’m trying to build a game with a whole list of randomly chosen questions from an XML file. Not sure if this is the best way to do it but i’ve got it setup like below.
Question is, is there a way to prevent the question from recurring?
I’ll probably end up with the user going through 10 questions from a bunch of 20 in the XML file.
Thanks heaps
============================================
RanNum = Math.floor(Math.random() * (3 - 0)) + 0;
function loadXML(loaded) {
if (loaded) {
_root.question = this.firstChild.childNodes[RanNum].childNodes[0].firstChild.nodeValue;
_root.answer1 = this.firstChild.childNodes[RanNum].childNodes[1].firstChild.nodeValue;
_root.answer2 = this.firstChild.childNodes[RanNum].childNodes[2].firstChild.nodeValue;
_root.answer3 = this.firstChild.childNodes[RanNum].childNodes[3].firstChild.nodeValue;
_root.answer4 = this.firstChild.childNodes[RanNum].childNodes[4].firstChild.nodeValue;
question_txt.text = _root.question;
answer1_txt.text = _root.answer1;
answer2_txt.text = _root.answer2;
answer3_txt.text = _root.answer3;
answer4_txt.text = _root.answer4;
} else {
content = "oh boy... file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“thequestions.xml”);
============================================