Please file a bug with a small test case. Alex Harui Flex SDK Developer Adobe Systems Inc.<http://www.adobe.com/> Blog: http://blogs.adobe.com/aharui
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Geoffrey Sent: Friday, October 30, 2009 1:35 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: SharedObject problem/bug? Cannot store a subclass of ByteArray. Hi Sean, Thank you for the link; still no luck. I had tried implementing IExternalizable before, but after reading your article I decided to try again. I have figured out a little more: --I can extend, say, a Sprite, and it works fine. --When I save the SharedObject, if I use the Sprite-based class, there are two calls to writeExternal(). But for the ByteArray-based class, there is no call to writeExternal(). --When I load the SO, the constructor for the Sprite-based class gets called. The constructor for the ByteArray-based class does not get called. I suspect that Adobe's serialization/deserialization code has something that checks for type ByteArray (e.g., if (x is ByteArray)). On the write-side, it would then call something like writeBytes(), and only call writeExternal() if not a ByteArray. On the read-side, it may do something similar when type casting. At this point, I will probably try a workaround for my situation. (E.g., encapsulating the ByteArray) But if anyone gets this to work, I would be interested to know. --Geoff --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, "seanmcmonahan" <s...@...> wrote: > > I'm having a similar problem with a subclass of Dictionary. Unfortunately I > haven't has an opportunity to try this fix yet, but maybe you'll find it > useful: > http://stackoverflow.com/questions/850466/properly-serializing-flash-utils-dictionary-to-a-sharedobject > > --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, > "Geoffrey" <geoffhom@> wrote: > > > > > > > > Muzak, thank you for your help. However, I have already tried [RemoteClass] > > (which I mentioned in the original post). I also looked at the link that > > you provided and decided to try more combinations, but none worked. I have > > tried [RemoteClass] with and w/o [Bindable], > > [RemoteClass(alias="ByteArrayPlus")], and I made sure to use my class > > beforehand. In all cases I can get a custom class to retain its type, but > > ByteArrayPlus always gets read as ByteArray from the SharedObject. > > > > I believe this may be a problem peculiar to ByteArray, but I don't know > > exactly why that would be so. > > > > Again, the challenge is this: make any class that extends ByteArray, write > > it to a SharedObject (to the disk), read it from the SharedObject, and have > > it retain its class. I know it sounds straightforward, but I cannot get it > > to work. > > > > --Geoff > > > > --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, > > "Muzak" <p.ginneberge@> wrote: > > > > > > Add a RemoteClass metadata tag to the custom class: > > > > > > Example at the bottom of the article > > > http://cookbooks.adobe.com/post_How_to_keep_the_type_of_your_objects_when_serializ-8323.html > > > > > > > > > ----- Original Message ----- > > > From: "Geoffrey" <geoffhom@> > > > To: <flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>> > > > Sent: Wednesday, October 28, 2009 12:45 PM > > > Subject: [flexcoders] SharedObject problem/bug? Cannot store a subclass > > > of ByteArray. > > > > > > > > > > Hi, > > > > > > > > I have a subclass of ByteArray (let's call it ByteArrayPlus), which I > > > > want to write to a SharedObject. I can store it fine, but > > > > when I read it back, it says it's of type ByteArray, not ByteArrayPlus. > > > > Does anyone have an idea what may be wrong? Has anyone > > > > gotten this to work? > > > > > > > > FYI, I am already using registerClassAlias(). And it works fine with a > > > > custom class, and with a custom class extending another > > > > custom class. I also tried implementing IExternalizable, but that did > > > > not help. I also tried [RemoteClass] and > > > > [RemoteClass(alias="ByteArrayPlus")]. > > > > > > > > Also, ByteArrayPlus is really simple: I only added a String (name) to > > > > it. > > > > > > > > This is my first post to FlexCoders. > > > > > > > > Any help appreciated. > > > > > > > > --Geoff > > > > > > > > > >