Flash não exibe dados carregados por XML
Fiz uma aplicação para rodar num CD ROM, um QUIZ em actionscript e XML.
Os dados são recebidos direito pelo Flash, usei trace para testar o código por partes, mas os dados não são exibidos nos text dinamicos determinados.
Podem me ajudar a resolver? :huh:
frame25
stop ();
var curQuizXML = new XML();
curQuizXML.ignoreWhite = true;
curQuizXML.onLoad = function(sucesso:Boolean) {
// Se "sucesso" for verdadeiro significa que o arquivo foi carregado
if (sucesso) {
_global.quizTitle = this.firstChild.childNodes[0].firstChild.nodeValue.toUpperCase();
_global.quizQuestions = this.firstChild.childNodes[1].firstChild.nodeValue;
_global.percentToPass = this.firstChild.childNodes[2].firstChild.nodeValue;
_global.credits = this.firstChild.childNodes[3].firstChild.nodeValue;
_global.sendEmail = this.firstChild.childNodes[4].firstChild.nodeValue;
_global.scoreToPass = Math.ceil(_global.quizQuestions * Number(_global.percentToPass));
gotoAndStop("Question");
} else {
// Avisa que ocorreu algum erro durante o carregamento
gotoAndStop("Problema");
}
};
curQuizXML.load("XML/settings.xml");
frame26
function randomizer() {
randomArray.randomize();
questionNum = randomArray[randomNum];
loadQuestion();
} // Fim da Função
function loadQuestion() {
answerTest.text = correctAnswer[questionNum];
CheckBoxVis();
questionTxt.text = question[questionNum];
aBox1.text = a0[questionNum];
aBox2.text = a1[questionNum];
aBox3.text = a2[questionNum];
aBox4.text = a3[questionNum];
trace(question[questionNum]);
} // Fim da Função
function CheckBoxVis() {
aCheckBox1._visible = false;
aCheckBox2._visible = false;
aCheckBox3._visible = false;
aCheckBox4._visible = false;
aBox1._visible = false;
aBox2._visible = false;
aBox3._visible = false;
aBox4._visible = false;
for (i = 0; i < totalAnswers[questionNum]; i++)
{
_root["aCheckBox" + (i + 1)]._visible = true;
_root["aBox" + (i + 1)]._visible = true;
} // Fim do for
} // Fim da Função
function aCheckBoxOver() {
this.gotoAndStop("checked");
} // Fim da Função
function aCheckBoxOut() {
this.gotoAndStop("unchecked");
} // Fim da Função
function selectedQuestion() {
function holdGo()
{
clearInterval(hold);
results_txt.text = "";
checkBoxEnabled();
nextQuestion();
} // Fim da Função
if (correctAnswer[questionNum] == selectedAnswer)
{
questionResults.push({question: Number(questionNum) + 1, answer: answerLetter + " CORRECT"});
totalCorrect = totalCorrect + 1;
results_txt.text = "CORRETO";
}
else
{
results_txt.text = "INCORRETO";
questionResults.push({question: Number(questionNum) + 1, answer: answerLetter + " WRONG"});
} // Fim do else if
checkBoxDisable();
var hold = setInterval(holdGo, 1500);
} // Fim da Função
function nextQuestion() {
if (randomNum == _global.quizQuestions - 1)
{
questionTxt._visible = false;
aCheckBox1._visible = false;
aCheckBox2._visible = false;
aCheckBox3._visible = false;
aCheckBox4._visible = false;
aBox1._visible = false;
aBox2._visible = false;
aBox3._visible = false;
aBox4._visible = false;
reOrder();
}
else
{
++randomNum;
questionNum = randomArray[randomNum];
loadQuestion();
updateQuizStatus();
} // Fim do else if
} // Fim da Função
function quizResults() {
totalPercentage = Math.round(totalCorrect / _global.quizQuestions * 100) + " %";
trace(totalPercentage);
if (totalCorrect >= scoreToPass)
{
_root.gotoAndStop("Passed");
}
else
{
_root.gotoAndStop("Failed");
} // Fim do else if
} // Fim da Função
function updateQuizStatus() {
quizStatusTxt.text = randomNum + 1 + " de " + _global.quizQuestions;
trace(randomNum + 1 + " de " + _global.quizQuestions);
} // Fim da Função
function reOrder() {
questionResults.sortOn("question", Array.NUMERIC);
for (i = 0; i < questionResults.length; i++)
{
questionInOrder.push(questionResults[i].question + " " + questionResults[i].answer);
} // Fim do for
quizResults();
} // Fim da Função
stop ();
var randomNum = 0;
var questionNum = 0;
var questionNum = 0;
var totalCorrect = 0;
var selectedAnswer = 0;
var answerLetter = "Nada selecionado";
var totalPercentage = 0;
var questionResults = new Array();
Array.prototype.randomize = function ()
{
var _loc2 = this.length;
if (_loc2 == 0)
{
return;
} // Fim do if
while (--_loc2)
{
var _loc3 = Math.floor(Math.random() * (_loc2 + 1));
var _loc5 = this[_loc2];
var _loc4 = this[_loc3];
this[_loc2] = _loc4;
this[_loc3] = _loc5;
} // Fim do while
return (this);
};
var qXML = new XML();
qXML.ignoreWhite = true;
var randomArray = new Array();
var question = new Array();
var a0 = new Array();
var a1 = new Array();
var a2 = new Array();
var a3 = new Array();
var correctAnswer = new Array();
var totalAnswers = new Array();
qXML.onLoad = function ()
{
for (i = 0; i < this.firstChild.childNodes.length; i++)
{
question.push(this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue);
a0.push(this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue);
a1.push(this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue);
a2.push(this.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue);
a3.push(this.firstChild.childNodes[i].childNodes[4].firstChild.nodeValue);
correctAnswer.push(this.firstChild.childNodes[i].childNodes[5].firstChild.nodeValue);
totalAnswers.push(this.firstChild.childNodes[i].childNodes[6].firstChild.nodeValue);
randomArray.push(i);
} // Fim do for
randomizer();
//trace(question);
};
qXML.load("XML/modulo1.xml");
definir_settings();
CheckBoxVis();
aCheckBox1.onRollOver = aCheckBoxOver;
aCheckBox2.onRollOver = aCheckBoxOver;
aCheckBox3.onRollOver = aCheckBoxOver;
aCheckBox4.onRollOver = aCheckBoxOver;
aCheckBox1.onPress = aCheckBoxOver;
aCheckBox2.onPress = aCheckBoxOver;
aCheckBox3.onPress = aCheckBoxOver;
aCheckBox4.onPress = aCheckBoxOver;
aCheckBox1.onRollOut = aCheckBoxOut;
aCheckBox2.onRollOut = aCheckBoxOut;
aCheckBox3.onRollOut = aCheckBoxOut;
aCheckBox4.onRollOut = aCheckBoxOut;
aCheckBox1.onRelease = function ()
{
selectedAnswer = 1;
answerLetter = "Answer=A";
selectedQuestion();
};
aCheckBox2.onRelease = function ()
{
selectedAnswer = 2;
answerLetter = "Answer=B";
selectedQuestion();
};
aCheckBox3.onRelease = function ()
{
selectedAnswer = 3;
answerLetter = "Answer=C";
selectedQuestion();
};
aCheckBox4.onRelease = function ()
{
selectedAnswer = 4;
answerLetter = "Answer=D";
selectedQuestion();
};
checkBoxDisable = function ()
{
aCheckBox1.enabled = false;
aCheckBox2.enabled = false;
aCheckBox3.enabled = false;
aCheckBox4.enabled = false;
};
checkBoxEnabled = function ()
{
aCheckBox1.enabled = true;
aCheckBox2.enabled = true;
aCheckBox3.enabled = true;
aCheckBox4.enabled = true;
aCheckBox1.gotoAndStop("unchecked");
aCheckBox2.gotoAndStop("unchecked");
aCheckBox3.gotoAndStop("unchecked");
aCheckBox4.gotoAndStop("unchecked");
};
var questionInOrder = new Array();
updateQuizStatus();Discussão (1)
Carregando comentários...