Re: [flexcoders] Storing object hierarchies in shared objects

2008-04-12 Thread Troy Gilbert
  - When serializing an object to the SharedObject, is the whole object
  hierarchy traversed? For example, if I have a model that stores a
  ParentObject which has an array of ChildObjects, and I stick the
  ParentObject in the SharedObject, when I retrieve it will I get back
  the ParentObject with a complete array of ChildObjects?

So, I ran some tests with writing objects to ByteArrays. It appears as
though all referenced objects are serialized as well, as deep as
necessary I assume. It also looks like it does the right thing and
only serializes any specific instance once, and when they're
reconstituted there's only one instance with potentially many inbound
references. Very cool.

Of course, unless there's something I'm missing, I'll have to manually
handle the case where I have two separately serialized object
hierarchies that had overlap... when they're reconstituted, there's no
linkage between the two hierarchies and the overlaps become duplicated
(and thus, no longer centralized/shared) data.

That scenario leads me to think that I may need to override the
default serialization to include an additional serialization of a
UUID, and then when the object is reconstituted register the UUID so
that if the object is reconstituted from another hierarchy it can be
located and references wired appropriately. Unless, of course, AS3
already does this for me (I wouldn't be surprised!). Any thoughts?

And for those with some AMF knowledge, what's the best way to store
AMF data on the server-side? For a lot of my data (that I don't need
indexed by the SQL database) I'd just assume not convert it to a PHP
object, translate it to its own row in the database, then reverse the
process. Do I just stick the AMF data in a BLOB (MySQL is my brand of
server if that matters)? Would I be better off dumping the blob to
disk and just storing its path in SQL? (Note: I realize this question
is veering a bit into DB admin territory -- we all wear multiple
hats!)

Thanks for the insights,

Troy.


Troy.


[flexcoders] Storing object hierarchies in shared objects

2008-03-28 Thread thirtyfivemph
I'm thinking about adding an auto-save feature to our RIA so that
users can navigate away from the app and not lose any data. The common
AJAXy approach (e.g. Gmail) is to periodically send updates back to
the server. But I'd like to avoid hitting the server with that regular
network traffic if I can, and I want something quicker than traversing
the wire...

So, I thought of local SharedObjects. They can store up to 100KB
without bugging the user (by default), which would be plenty. I've got
a few questions, though, because I can't find anything but very
trivial examples.

- When serializing an object to the SharedObject, is the whole object
hierarchy traversed? For example, if I have a model that stores a
ParentObject which has an array of ChildObjects, and I stick the
ParentObject in the SharedObject, when I retrieve it will I get back
the ParentObject with a complete array of ChildObjects?

- I'm guessing the above question probably relates to the default
behavior of AMF3 serialization, which I know can be customized by
defining the IExternalizable interface and implementing the read/write
bytes methods... anyone have any pointers on writing robust r/w methods?

- From what I get in the documentation, it sounds like the *default*
Player security is such that I could store a local SharedObject
smaller than 100KB with virtually guaranteed success. Of course, if
the user has disabled local storage all together, it won't work, in
which case I'll need to prompt the user about it. Is there any
existing examples or libraries that provide a good, robust handling of
a local persistence, i.e. handling the edge cases gracefully and/or
prompting the user appropriately?

Thanks,

Troy.