xml conection
hi , i wrote following code quiz game :
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)// ver se mesma é correcta
{
this.correctanswer = this.numofanswers; //para uma pergunta correcta existe uma resposta certa
} // end if
++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(19);
}
else//se uma resposta errada vai para frame 20
{
gotoandplay(20);
} // end else if
};
this.getnumofanswers = function ()
{
return (this.answers.length);//resposta em numero
};
} // end of function
function onquizdata(success)//caso o data quiz seja carregado com sucesso
{
var quiznode = this.firstchild;
var quiztitlenode = quiznode.firstchild;
title = quiztitlenode.firstchild.nodevalue;
var = 0;// o numero complexo i=0
var itemsnode = quiznode.childnodes[1];
while (itemsnode.childnodes[i])
{
var itemnode = itemsnode.childnodes[i];
var questionnode = itemnode.childnodes[0];
quizitems[i] = new quizitem(questionnode.firstchild.nodevalue);
var = 1;
var answernode = itemnode.childnodes[a++];
while (answernode)
{
var iscorrectanswer = false;
if (answernode.attributes.correct == "y")
{
iscorrectanswer = true;
} // end if
quizitems[i].addanswer(answernode.firstchild.nodevalue, iscorrectanswer);
answernode = itemnode.childnodes[a++];
} // end while
++i;
} // end while
gotoandplay(_currentframe + 1);
} // end of function
var quizitems = new array();
var mydata = new xml();
mydata.ignorewhite = true;
mydata.onload = onquizdata;
mydata.load("questionario/questionario.xml");
stop ();
-//--
i'd put picture on each question.
someone can me, tanks
More discussions in ActionScript 1 and 2
adobe
Comments
Post a Comment