0
我正在創建一個名爲QuizMaker的遊戲。
遊戲的測驗是外部.xml文件,QuizMaker將通過我的類QuizXML導入.xml文件。 每個測驗都包含有答案的問題,可能是圖像的形式,也可能是文本或其他形式。 玩家應該能夠在QuizMaker內導航文件夾「我的測驗」。
爲此,我需要該文件夾中的文件列表。
這裏是未完成的getter函數,以及我的問題:如何獲取文件列表?AS3 - 獲取,創建和保存XML文件
//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;
}
我的第二個問題是,我怎麼能保存的文件夾「我的測驗」,在XML文件?
這些都是未完成的setter函數:
//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
}
}
感謝您閱讀我的問題。
我們可以安全地假設您使用AIR嗎? – shaunhusain 2012-08-15 16:45:23