Hi could anyone tell me what is going wrong with my quiz? I want to randomise the order by telling Flash to assign the variable shufflearray to the question nodes but it doesnt seem to work when I try this.

The code is below:

function QuizItem(question)
{
this.question=question;
this.answers=new Array();
this.numOfAnswers=0;
this.correctAnswer=0;
this.getQuestion=function()
{
return this.question;
}
this.addAnswer=function(answer, isCorrectAnswer)
{
this.answers[this.numOfAnswers]=answer;
if (isCorrectAnswer)
this.correctAnswer=this.numOfAnswers;
this.numOfAnswers++;
}

this.getAnswer=function(answerNumberToGet)
{
return this.answers[answerNumberToGet];
}

this.getCorrectAnswerNumber=function()
{
return this.correctAnswer;
}

this.checkAnswerNumber=function(userAnswerNumber)
{
if (userAnswerNumber==this.getCorrectAnswerNumber())
gotoAndPlay(22);
else
gotoAndPlay(32);
}
}

function onQuizData(success)
{
var quizNode=this.childNodes[0];
var quizTitleNode=quizNode.firstChild;
title=quizTitleNode.firstChild.nodeValue;

var i=0;
// <items> follows <title>
var itemsNode=quizNode;
while (itemsNode.childNodes[i])
{
var itemNode=itemsNode.childNodes[i];
// <item> consists of <question> and one or more <answer>
// <question> always comes before <answer>s (node 0 of <item>)
var questionNode=itemNode.childNodes[0];
quizItems[i]=new QuizItem(questionNode.firstChild.nodeValue);
var a=1;
// <answer> follows <question>
var answerNode=itemNode.childNodes[a++];
while (answerNode)
{
var isCorrectAnswer=false;
if (answerNode.attributes.correct=="y")
isCorrectAnswer=true;
quizItems[i].addAnswer(answerNode.firstChild.nodeValue, isCorrectAnswer);
// goto the next <answer>
answerNode=itemNode.childNodes[a++];
}
i++;
}

//I think you need to make an array 1 to maxNumberOfQuestions i.e

function sortRand () {
if (random(2) == 0) {
return -1;
}
if (random(2) == 0) {
return 1;
}
}
questionarray = [1,2,3,4,5,6,7,8,9,10,11,12];
shuffledArray = questionarray.sort(sortRand); //trace(shuffledArray);

//use this shuffled array to access different nodes of your quiz xml i.e.

nextQuestion = QuizItem[shuffledArray[0]]; <!--This is the line -->

delete shuffledArray[0];

//then delete shuffledArray[0]

////////////

gotoAndStop(12);
}

var quizItems=new Array();
var myData=new XML();
myData.ignoreWhite=true;
myData.onLoad=onQuizData;
myData.load("Quiz 1 - How youll develop the skills & reasons -1144.xml");

Thanks

Chris Girgg