3

I want to save the application state that contains some UIcomponents as shown in image.

enter image description here

When the user leaves the editing mode the work should save in some form so the user can edit later.

I'm not able to retrieve data from sharedObject.

Instead, now I would like to use IExternalization. How I use this to save user work?

Devendra
  • 1,864
  • 6
  • 29
  • 49

1 Answers1

0

This question has an example of IExternalizable usage.

You have a number of UIComponents descendants, perhaps they even share a parent. So, you take each of the classes and write that they implements IExternalizable, and write a coherent writeExternal and readExternal pair of methods, saving only the required properties (x, y, type, whatever else. Say a resistor, you save its x, y, type as enum or String, probably rotation, and that's all. When you do a readExternal implementation, you read all the values in the same order you wrote them, and then reconstruct anything and everything within the object from the values you read. Anything external to the object should be restored by its parent, which will write a set of these objects (resistors, inductors, transistors etc) one by one, then will addChild() them at reading. This is a complicated enough structure, but will work if done properly.

Yes, all this is able to be stored inside a SharedObject, with its natively available methods. Take care though, you will need to call a registerClassAlias method for all classes involved in IExternalizable implementation.

Community
  • 1
  • 1
Vesper
  • 18,599
  • 6
  • 39
  • 61