I am a student and have to build a flex air desktop software using Flash Builder 4.5. I decided on a simple spark tabnavigater with tabs of, BuildCharacter, BuildWorld, BuildOject and WriteStory. Each of these panes have textareas and textinput components that the user can enter data into.
How do I let the user save all his input data in a single file. if the user then clicks file open, and clicks on that file, it loads all that data back into their place in the tabnavigator, and the the user can edit or continue. If the user creates a new project, it must load all the tabnav panels as empty.
I understand how to save just the text from the Richtexteditor into the textfile, but if I do this for all the tabs, then the user will have to save each tabs inputs seperately. That is not how software works.
I have searched all over but can only find the saving to a database or saving single component data in a filename that is predetermined, not user defined.
If you can help me with this I’d be really greatfull. I don’t mind learning just point me to the place that has the information.
Thanks
I’ve done this before. I don’t have my code with me right now, but the general idea is to declare a class “myData” that has a bunch of properties (“BuildCharacterText”, “BuildWorldText”, etc).
When the user clicks ‘save’, iterate over your tabs and populate an instance of this class. All you need do then is stream this single object to a file.
Similarly, on start up if the file is missing or empty, create an empty object then pass it to a routine that “unpacks” it to the tabs. If the file had data, read the file in and pass the object.
There’s a relevant writeup on streaming objects to disk at switchonthecode.