Writing to and retriveing from a file: List in Flex!

Tags: xml flex file air list

I am Totally new to flex and Action script.. I have a List control in my Air application. When I install the application I want a file created automatically on the local folder, and then when I start using the application .i.e. start typing in the List control, after exiting the application I want this data saved in that file and when I open the application back, the list is loaded from the file.

I have read a couple of discussions about this issue but they all involve just textinputs not List controls.. Can someone guide me on how it is done best, and if what I have to use is XML, then how to load and write back to the list control using XML ...

This is just an idea, I haven't tried it: Why not just save the ListBase data object to a ByteArray using writeObject, then save that to a binary file, or even better the EncryptedLocalStore? Then use the ByteArray readObject to restore it when your application loads--no XML required.

I don't quite understand the question. Are you using an editable list control to change the data in the list?

If you bind the List control's dataProvider to an ArrayCollection, you should be able to listen for the ArrayCollection's CHANGE event and write the new data to the file at that point. Whether that works or not might depend on the type of data you have in the ArrayCollection.

Another option is to listen to the itemEditEnd event. See here:


By : Osman

"I just want what ever happens to be saved when the application exits and once it is started again the list is loaded with the updated data."

First of all, flash player run SWFs in a sandbox, whose security setting doesn't allow local file system access. So you won't be able to write into local file. If you want your application to save something, you need to think about sending data to server and retrieving back when application starts.

This video can help you solving your question :)
By: admin