views:

87

answers:

1

Hi,

I try to serialize objects with their private attributes, in Flex.

The introspection API does not seem to allow it: "The describeType() method returns only public members. The method does not return private members of the caller's superclass or any other class where the caller is not an instance."

Is there another way for an instance to know the name of its private members?

+2  A: 

Unfortunately, the describeType() method is the only way to do introspection in Flex. People have written wrappers around it, and if you want to do introspection then I'd recommend as3-commons-reflection, but there is no way to list the private attributes of a class and no way to access them even if you could list them.

Andrew Aylett
Thanks for the tips about as3-commons-reflection."and no way to access them even if you could list them." : I thought about adding a method called something like "save()" into each classes which must be serialized. The code of this method would be included (include directive in as3). So the best would be to include a generic code which list private attributes, and save their values. Knowing the name of the attribute, accessing their values is not a problem (because the save() is also into the class). But listing private attributes' names seems impossible... :o(
mensonge
I'd contemplated writing something about explicit serialisation functions, but that don't always work -- if you need to serialise framework objects with private attributes then you're out of luck :(.
Andrew Aylett