# Flash quiz using xml for questions and answers

**URL:** https://forum.kirupa.com/t/flash-quiz-using-xml-for-questions-and-answers/196132
**Category:** flash
**Created:** [August 5, 2006, 9:23pm UTC](https://forum.kirupa.com/t/flash-quiz-using-xml-for-questions-and-answers/196132 "2006-08-05T21:23:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![somnamblst](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@somnamblst](https://forum.kirupa.com/u/somnamblst)
#### Post date: [August 5, 2006, 9:23pm UTC](https://forum.kirupa.com/t/flash-quiz-using-xml-for-questions-and-answers/196132/1 "2006-08-05T21:23:15Z")

</div>

What do I need to remove so the questions will be asked in order rather than randomly shuffled each time the quiz loads?

The AS on frame1

// XML Question Loader - Jim Bumgardner  
qList = new Array();  
nbrUsed = 0;  
// This is a recursive function that  
// walks thru all the nodes in your XML  
// and loads up the ones you’re  
// interested in into the qList array.  
loadNode = function(it)  
{  
if (it.nodeName == ‘question’) {  
var qSet = new Array();  
qSet.q = it.attributes[‘q’];  
qSet.used = false;  
qSet.ans\_a = it.attributes[‘ans\_a’];  
qSet.ans\_b = it.attributes[‘ans\_b’];  
qSet.ans\_c = it.attributes[‘ans\_c’];  
qSet.ans\_d = it.attributes[‘ans\_d’];  
qSet.ans\_e = it.attributes[‘ans\_e’]; // just in case there are more than 4…  
qSet.ans\_f = it.attributes[‘ans\_f’];  
qSet.right = it.attributes[‘right’];  
qList.push(qSet);  
}  
else if (it.nodeName == “questionList”)  
{  
// process any questionList properties here  
// - there aren’t any at the moment.  
// Note that the ‘questionList’ tag is  
// completely ignored - this will still  
// work without that tag.  
}  
if (it.hasChildNodes()) {  
for (var i = 0; i \< it.childNodes.length; ++i)  
loadNode(it.childNodes\*);  
}  
}  
// when this function is called, we’re done loading  
// - do something with your data.  
// Most likely you want to jump to a frame in your movie where you play the game, but I’ll just output a few values  
function finishInit()  
{  
trace(qList.length + " questions loaded:");  
// determine maximum score  
maxscore = qList.length\*10;  
// randomly shuffle list of questions  
qList.sort(function() { return random(3) - 1;});  
questionNbr = 0;  
gotoAndPlay(2);  
}  
var myxml = new XML();  
myxml.onLoad = function()  
{  
// initialize array again, in case  
// we’re calling this twice…  
qList = new Array();  
loadNode(this);  
finishInit();  
}  
myxml.load(“questions.xml”);  
// A common mistake is to attempt to access the data here. Don’t – it is not loaded at this point  
// myxml.load() is an asynchronous function - it returns before it is finished.  
// The finishInit() function (above) will be called when the data is ready to go…  
stop();
