Hello All:
I am having a problem with a little trivia game that I am in the process of developing. What I am trying to do is have flash fade out one wrong answer at a time. All questions are being pulled from an XML file that has hundreds of questions. Keep in mind that the correct answer will not always be in the same spot. I also have it so that one question fades into another after a specific time. Here is the code
System.useCodepage = true;
//
function loadXML(loaded) {
if (loaded) {
xmlNode = xmlData.firstChild;
answerA = [];
answerB = [];
answerC = [];
question = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
question* =
xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
answerA* =
xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
answerB* =
xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
answerC* =
xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
ans_txt.text = "A:";
q_txt.text = "Q:";
}
firstImage();
//veryfirstImage();
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("multiple_trivia.xml");
/////////////////////////////////////
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
desc_txt.text = question[p];
answer_txt.text = answer[p];
slideshow();
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
desc_txt.text = question[p];
answer_txt.text = answer[p];
}
}
function veryfirstImage() {
var randomNum:Number = Math.floor(Math.random(total)*total);
p = randomNum;
if (loaded == filesize) {
desc_txt.text = question[p];
answer_txt.text = answer[p];
slideshow();
picture_num();
}
}
function picture_num() {
current_pos = p+1;
curtxt.text = current_pos+" / "+total; } // minutes = 0; seconds = 59; // var min = minutes; var sec = seconds; delay = 1000;
//-----------------------
var my_fmt:TextFormat = new TextFormat(); my_fmt.bold = true;
//-----------------------
this.onEnterFrame = function() {
if (sec<=36) {
my_fmt.color = 0xFFFF00;
TimeText.setNewTextFormat(my_fmt);
}
if (sec<30) {
TimeText.text = "Time's Up!!!!!!";
answer_txt._alpha = 100;
ans_txt._alpha = 100;
//answer_txt._alpha += 15;
//ans_txt._alpha += 15;
} else {
answer_txt._alpha = 0;
ans_txt._alpha = 0;
}
if (answer_txt._alpha>=15) {
TimeText.text = "";
}
};
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
sec--;
var display_seconds = Math.abs(sec-30);
if (display_seconds<10) {
display_seconds = "0"+display_seconds;
}
if (sec == 0) {
clearInterval(myInterval);
if (min == 0) {
my_fmt.color = 0xFFFFFF;
TimeText.setNewTextFormat(my_fmt);
//-------------------------
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
sec = seconds;
min = minutes;
}
// Display minutes and
seconds.
TimeText.text = "Time Left: "+min+":"+display_seconds;
}
}
stop();
var spc:Number = 10;
for (i=0; i<4; i++) {
duplicateMovieClip(ans, "ans"+i, i); } this.onEnterFrame = function() {
ans1._y = (desc_txt._y+desc_txt._height)+spc;
ans2._y = (ans1._y+ans1._height)+spc;
ans3._y = (ans2._y+ans2._height)+spc; }; // var intervalId:Number; var count:Number = 0; var maxCount:Number = 3; var hideanswer:Number = 2; var duration:Number = Math.abs(1000*hideanswer); var answer:Array = new Array("wrong", "wrong", "correct"); // function executeCallback(param:String) {
clearInterval(intervalId);
if (count<maxCount) {
count++;
//-------------------------------------------------------
for (i=0; i<3; i++) {
var remove = xmlData.firstChild.childNodes[p].childNodes*;
ans1.answer_txt.text = "A) "+remove.nodeName
if (remove.nodeName !== answer[2]) {
this.onEnterFrame = function() {
if (this["ans"+i]._alpha>=0) {
this["ans"+i]._alpha -= 25;
}
};
}
}
//-------------------------------------------------------
intervalId = setInterval(this, "executeCallback", duration, answer[count]);
}
}
if (intervalId != null) {
clearInterval(intervalId);
}
intervalId = setInterval(this, "executeCallback", duration, answer[count]); // function firstImage() {
p = 0;
if (loaded == filesize) {
desc_txt.text = question[p];
ans1.answer_txt.text = "A) ";
//ans1.answer_txt.text = "A) "+answerA[p];
ans2.answer_txt.text = "B) "+answerB[p];
ans3.answer_txt.text = "C) "+answerC[p];
slideshow();
findAnswer();
picture_num();
}
}
Here is the XML code:
<questions>
<question>What Year the Disney world Start?</question>
<correct>1971</correct>
<wrong>1955</wrong>
<wrong>1980</wrong>
</question>
</questions>
:stunned: