Answer the question
In order to leave comments, you need to log in
Actionscript3.0 for android - how to save data in the game?
Hello.
I have a question. There is, for example, a game, and you have passed the first level, you need to save this information so that the user does not pass it again, how to do this?
Please post some code or links.
Thank you!
Answer the question
In order to leave comments, you need to log in
Once I wrote a class for working with files in Air-e
package ua.alexvoz.arena.utils {
import flash.display.Sprite;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
/**
* @author ALeXVoz
* http://alexvoz.net/
* E-mail: [email protected]
* ICQ: 232-8-393-12
* Skype: alexvozn
*/
public class FileUtils extends Sprite {
public function FileUtils() {
super();
}
public static function createDocumentDerictory(dirName:String):void {
var _dir:File = File.applicationStorageDirectory.resolvePath(dirName);
if (!_dir.exists) _dir.createDirectory();
}
public static function saveUTFTextFile(flName:String, flData:String):void {
var _fl:File = File.applicationStorageDirectory.resolvePath(flName);
var _flStream:FileStream = new FileStream();
_flStream.open(_fl, FileMode.WRITE);
_flStream.writeUTFBytes(flData);
_flStream.close();
}
public static function openUTFTextFile(flName:String):String {
var _fl:File = File.applicationStorageDirectory.resolvePath(flName);
var _flStream:FileStream = new FileStream();
_flStream.open(_fl, FileMode.READ);
_flStream.position = 0;
var _data:String = _flStream.readUTFBytes(_flStream.bytesAvailable);
_flStream.close();
return _data;
}
public static function checkFileCreated(flName:String):Boolean {
var _dir:File = File.applicationStorageDirectory;
if (_dir.resolvePath(flName).exists) return true
else return false;
}
public static function checkDirCreated(dirName:String):Boolean {
var _dir:File = File.applicationStorageDirectory.resolvePath(dirName);
if (_dir.exists) return true
else return false;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question