Could be. But forgive If I don't realize: how could I read the fileStream in that way?
Right now I read it this way: while(stream.bytesAvailable){ arr = stream.readObject() as DocumentFile;//bad cast } I also tried this: arr[0] = stream.readObject() as DocumentFile;//assigns the last DocumentFile saved in the file.. ____________________________________ Claudio M. E. Bastos Iorio From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Thursday, August 14, 2008 1:21 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: writeObject() and readObject() I would write out the number of DocumentFiles before writing them out, then when reading, I'd read that number and know how many to expect _____ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Claudio M. E. Bastos Iorio Sent: Wednesday, August 13, 2008 9:13 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: writeObject() and readObject() Thanks for answer. But what can I do if I have many DocumentFile objects written in the file? Is there any way to retrieve all objects or filter by value name/id..? just like a database o e4x.. ____________________________________ Claudio M. E. Bastos Iorio From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Thursday, August 14, 2008 12:20 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: writeObject() and readObject() If you wrote an instance of DocumentFIle, you need to read back an instance of DocumentFIle _____ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of slackware2142 Sent: Wednesday, August 13, 2008 5:57 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: writeObject() and readObject() I forgot to mention that I'm using FLEX3 and my class (DocumentFile) is already registered: [RemoteClass(alias="com.DocumentFile")] public class DocumentFile extends EventDispatcher { ... ) ____________________________________ Claudio M. E. Bastos Iorio --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "slackware2142" <[EMAIL PROTECTED]> wrote: > > 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 >