Hi! I'm trying to create a simple 'file database' in AIR.
I know I can save and restore objects in AMF format using the methods 
write/restoreObject.

here is my code to save:

var DocumentToSave:DocumentFile = new DocumentFile(); //DocumentFile 
is a custom class
DocumentToSave.Name = 'some name';
var file:File = File.applicationStorageDirectory.resolvePath
('myApp.data');
var stream:FileStream = new FileStream();
stream.open(file, FileMode.APPEND);
stream.writeObject(DocumentToSave);

That code is working and stores the DocumentFile objects and values. 
But, what can I do to retrieve that objects (or any particular 
object).

I tried this to retrieve:

var file:File = File.applicationStorageDirectory.resolvePath
('myApp.data');
var stream:FileStream = new FileStream();
stream.open(file, FileMode.READ);
var arr:Array = new Array();
while(stream.bytesAvailable){
//what can I use here to create an array of DocumentFiles stored 
in 'myApp.data'?
arr = stream.readObject() as Array; //seems to work
}

trace('new arr length: ' + arr.length);//doesn't work, why??

Any help?

Thanks in advance!


____________________________________
Claudio M. E. Bastos Iorio




Reply via email to