Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 can't load XML file
    primarykey
    data
    text
    <p>I'm making a quiz app on flash builder with AS3.</p> <p>I want to load a XML file to get my questions. But I think I can't load my XML file. I googled alot. I searched the forums. But nothing worked. I just don't see my error here.</p> <p>When I click the button I want to see on my stage if my XML file is loaded. But in this case I don't get any value on my stage. </p> <p>Quiz.as</p> <pre><code>package { [SWF('width'= 800, 'height' = 600, 'frameRate'=40)] public class Quiz extends Sprite { // gloabal container public static var container:Sprite = new Sprite(); // button object public var btnMulti:MyButton = new MyButton(); public function Quiz() { init(); } private function init():void { addChild(container); makeMenu(); } private function makeMenu():void { btnMulti.buttonText = "multipleChoice"; btnMulti.x = 50; btnMulti.y = 20; btnMulti.addEventListener(MouseEvent.CLICK, multiHandler); // add button to the stage container.addChild(btnMulti); } private function multiHandler(e:MouseEvent):void { // if button clicked make a Question object var q:Question = new Question(); // get the value var questionText:String = q.getter; // print the value in a textfield on the stage var tField:TextField = new TextField(); tField.text = questionText; container.addChild(tField); } } } </code></pre> <p>Question.as</p> <pre><code>public class Question extends Sprite { private var test:String; public function Question() { // xml var urlReq:URLRequest = new URLRequest("./files/multiplechoice.xml"); var urlLoad:URLLoader = new URLLoader(); urlLoad.addEventListener(Event.COMPLETE, textLoaded); urlLoad.load(urlReq); } private function textLoaded(e:Event):void { XML.ignoreWhitespace = true; var xml:XML = new XML(e.target.data); // check if loaded test = "xml loaded"; } // getter public function get getter():String { return test.questionText; } } </code></pre> <p>multiplechoice.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;multipleChoice&gt; &lt;questionSet&gt; &lt;question&gt;Question 1&lt;/question&gt; &lt;answer correct="yes"&gt;Answer 1&lt;/answer&gt; &lt;answer&gt;Answer 2&lt;/answer&gt; &lt;answer&gt;Answer 3&lt;/answer&gt; &lt;answer&gt;Answer 4&lt;/answer&gt; &lt;/questionSet&gt; &lt;questionSet&gt; &lt;question&gt;Question 2&lt;/question&gt; &lt;answer correct="yes"&gt;Answer 1&lt;/answer&gt; &lt;answer&gt;Answer 2&lt;/answer&gt; &lt;answer&gt;Answer 3&lt;/answer&gt; &lt;answer&gt;Answer 4&lt;/answer&gt; &lt;/questionSet&gt; &lt;questionSet&gt; &lt;question&gt;Question 3&lt;/question&gt; &lt;answer correct="yes"&gt;Answer 1&lt;/answer&gt; &lt;answer&gt;Answer 2&lt;/answer&gt; &lt;answer&gt;Answer 3&lt;/answer&gt; &lt;answer&gt;Answer 4&lt;/answer&gt; &lt;/questionSet&gt; &lt;/multipleChoice&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload