newbie here to AS3, did a little in school but been out of the game for a while.
So my problem is; I have 5 dynamic text boxes in flash. One being the question asked and the other 4 are the potential answers. I have been able to get the text to display from the XML file, that works fine, but my problem is that it tries to display all the questions at once instead of one at a time.
Would a loop fix something like this? Unsure what way to go about it because I'm still fairly new to AS3.
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
var xmlData:XML = new XML();
var theURL_ur:URLRequest = new URLRequest("questions.xml");
var loader_ul:URLLoader = new URLLoader(theURL_ur);
loader_ul.addEventListener("complete", fileLoaded);
function fileLoaded(e:Event):void
{
xmlData = XML(loader_ul.data);
question_txt.text = xmlData.question
one_txt.text = xmlData.option1
two_txt.text = xmlData.option2
three_txt.text = xmlData.option3
four_txt.text = xmlData.option4
}
and here is the xml file. What I would like it to do is to display one question and then go onto the next question after you have answered the previous question not display all the questions at once. Hope I am making sense here :)
<?xml version="1.0"?>
<allquestions>
<question>What is the Capital of Australia?</question>
<option1>Melbourne</option1>
<option2>Canberra</option2>
<option3>Sydney</option3>
<option4>Brisbane</option4>
<question>Who was the first Prime Minister of Australia?</question>
<option1>John Howard</option1>
<option2>Sir Edmond Barton</option2>
<option3>Computers</option3>
<option4>Some other guy</option4>
No comments:
Post a Comment