Hi, I am trying to make a generic multiple choice quiz, with questions to be loaded from an xml file. The hope is that I can give it to teaching colleagues as a resource, and they can create their own questions by just altering the xml file, as none of them know how to use flash.
I can make all of it work beautifully for just one xml file's worth of questions, but I'd like to enable people to save several different xml files with different questions, and choose which one to use in the first frame of my swf.
Here's what I have in the first frame, where there is simply a text input box (inputxml) and a 'Go' button.
Actionscript Code:
stop ();
Go.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);
var chosenFile:String
function fl_ClickToGoToNextFrame(event:MouseEvent):void
{Go.removeEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);
chosenFile = inputxml.text;
nextFrame();
}
On the next page, it all starts like this:
Actionscript Code:
var xmlDoc:XML = new XML();
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("Questions2.xml");
loader.load(req);
loader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(evt:Event):void {
loader.removeEventListener(Event.COMPLETE, completeHandler);
xmlDoc = XML(evt.target.data);
quizTitle.text = String(xmlDoc.quizTitle.@title);
};
It works as long as I specify
Actionscript Code:
var req:URLRequest = new URLRequest("Questions2.xml");
but when I try to swap this for
Actionscript Code:
var req:URLRequest = new URLRequest(chosenFile);
where chosenFile is "Questions2.xml", it won't work, and gives me this error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: file:////Volumes/Macintosh%20HD/Users/millycampling/Documents/00%20Flash/Multiple%20Choice/
Questions2.xml
I have just changed over from Flash Pro 8 to CS5, and AS3 is still a bit new to me - am I doing something really daft?