I am creating a game called QuizMaker.
The quizzes for the game is external .xml files, which QuizMaker will import, through my class QuizXML.
Every quiz contains questions with answers, maybe in form of images, maybe in form of text or whatever.
The player should be able to navigate the folder “My Quizzes” inside QuizMaker.
To do so I need a list of files in that folder.
Here is the uncompleted getter functions, and my question: How do I get the list of the files?
//returns an array of paths to folders and/or .xml files from the folder "My Quizzes"
public function getFolders():Array {
var folders:Array = new Array();
//if .xml or a folder is the file looking at, add the file path to folders
return folders;
}
//returns an array of .xml file paths from an array consisting of file paths
//if a folder, which contains .xml files, is encountered from the array, add the .xml file paths to an array
public function getQuizzes(folders:Array):Array {
var validXML:Array = new Array();
for(var curPath:uint=0;folders.length>curPath;curPath++) {
//if folders[curPath] is a folder
//somehow look through the folder's content
//if .xml is the file looking at, add the file path to validXML
//else if .xml is the file looking at, add the file path to validXML
}
return validXML;
}
My second question is, how can I save XML files in the folder “My Quizzes”?.
These are the uncompleted setter functions:
//creates new folders inside "My Quizzes" from an array, which contains the folders' names as strings
//if a folder with the same name is encountered, don't override that folder
public function setFolders(folderNames:Array):void {
for(var curPath:uint=0;folderNames.length>curPath;curPath++) {
//if a folder exists as folderNames[curPath]
//do nothing
//else create a folder called folderNames[curPath]
}
}
//creates new .xml files from an array, which contains XML objects, inside a folder from a string
//if an .xml file with the same name as an XML object's nameFile is encountered, don't override that .xml file
public function setQuizzes(outputPath:String,objectsXML:Array):void {
for(var curXML:uint=0;objectsXML.length>curXML;curXML++) {
//if an .xml file exists as objectsXML[curXML].nameFile
//do nothing
//else create objectsXML[curXML] as an .xml file
}
}
Thanks for reading my question.
FileReference may be what you are looking for.
It allows user to browse for a file and the app to save to the filesystem.