我試圖將單個單詞保存到文件中,然後閱讀該單詞以確認成功。當讀取文件的代碼運行時,它不返回任何數據。而且,我無法驗證是否創建了任何文件。如何保存到文件?在iOS上使用AS3(初學者)
下面是代碼:
// This is run at the beginning of the frame, and this does display Hello in a textArea
var str:String = "Hello\n";
feedback.text = str;
// This is run when the user taps a button
var myFile:File = File.applicationStorageDirectory.resolvePath("./eFiveV3/text.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(myFile,FileMode.WRITE);
fileStream.writeUTF(str);
fileStream.close();
str = "Goodbye\n";
// if the code below is run, then the feedback box will be empty. if the code below is commented out, then the feedback box will contain the text: Goodbye
fileStream.open(myFile,FileMode.READ);
str = fileStream.readMultiByte(myFile.size,File.systemCh arset);
fileStream.close();
feedback.text = str;
任何幫助,將不勝感激:)
感謝你了。我嘗試切換到readUTF並且它第一次工作。而且,你的解釋也很有幫助。我對使用ActionScript很感興趣,但仍有很多東西需要學習。 –