This is a Flash application to be deployed in Android device thru Adobe Air. I am trying to save the username and score (boxTwo.text + _clickTxt.text) of the user in a notepad .txt file, without any dialog box appearing in android device. It will be generated once the save button (btnSave) is pressed. I can't make it work. Thanks! This is my code:
import flash.net.FileReference;
import flash.events.Event;
var so:SharedObject = SharedObject.getLocal("Test");
var f:File=new File("path\to\file.txt")
var str:FileStream=new FileStream();
btnSave.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
so.data.saveData = currentFrame;
so.flush();
}
btnSave.addEventListener (MouseEvent.CLICK, saveFile)
function saveFile(evt):void
{
str.open(f, FileMode.WRITE);
str.writeUTFBytes(boxTwo.text + _clickTxt.text);
str.close();
}
By Default Adobe Air does not allow to write files to any directory You can get writing access only to:
a directory that was been chosen by "browseForDirectory()" dialog box
fileVariable.browseForDirectory("Choose a directory");
(There are other directories specific for each platform but generally they are these 3 types) So just change your path to an allowed directory