0
我正在使用Filestream將分數保存在我的Android遊戲中。最近,我決定增加額外的水平。對於這些級別,我需要跟蹤多種類型的分數。這裏是我的一個變量代碼:文件流(AS3)中的多個變量
function writePion(): void { //First function to create/write in the file
var pion: Object = new Object();
pion.value = numeroPion; //value of object = variable value
trace("Pion (writeObject value)= " + pion.value);
var file2: File = File.applicationStorageDirectory.resolvePath("pion.menes");
var fileStream2: FileStream = new FileStream();
fileStream2.open(file2, FileMode.WRITE);
fileStream2.writeObject(pion);
fileStream2.close();
};
function readPion(): void { //second function to read the file and modify the variable.
var file2: File = File.applicationStorageDirectory.resolvePath("pion.menes");
if (!file2.exists) {
return;
}
var fileStream2: FileStream = new FileStream();
fileStream2.open(file2, FileMode.READ);
var pion: Object = fileStream2.readObject();
numeroPion = pion.value; //update the variable
trace("pion (readObject value)= " + numeroPion)
fileStream2.close();
};
我想知道如果我一定要做出的每個類型的功能分數,或者是否是有一個適應它來保存(約10)新變量的方法?感謝:) Jeryl。
我剛剛嘗試過,它完美地工作。非常感謝你! – Jeryl 2015-02-07 19:37:00