views:

320

answers:

3

Hi People :) ,

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 ...

A: 

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.

John Lemberger
thank you ... I will try that :)
One thing to keep in mind though - this may create problem if you upgrade your app after a change in framework library classes. Say, if you upgraded from Flex 3 to 4 and want to read the data saved from the Flex 3 version.
Chetan Sastry
A: 

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:

http://livedocs.adobe.com/flex/3/html/celleditor%5F7.html#194259

Osman
Thank you .. yes it's an editable list .. empty in the beginning then as the user starts using the application, he types in it gradually, inserting , editing or deleting rows from it.. 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.
A: 

"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.

He said it is an AIR application.
Chetan Sastry