Here is a good blog post regarding this topic:

 

http://www.brooksandrus.com/blog/2008/03/25/flex-air-serialization-lesso
ns-learned/

 

One thing it doesn't describe is how to deal with classes that have a
constructor with args.

The way to deal with that is to have default values for the args in the
constructor.

When an object is deserialized, the constructor is automatically
invoked, but in the case of a constructor that has arguments, the
constructor invocation during the deserialization process has no values
to pass to the constructor.  Having default values for constructor args
alleviates this issue and avoids an error being thrown.  In the
readExternal method (implemented as part of the IExternalizable
interface) you can carry out the operations that the constructor
normally would with values read from the serialized object.  This will
result in a deserialized object that will look as it would if it had
been created by calling it with constructor args.

 

FYI, I'll have a sample for this up on my blog in the next few days
(http://flexmonkeypatches.com <http://flexmonkeypatches.com/> )

 

HTH

 

-Kyle

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Battershall, Jeff
Sent: Thursday, March 27, 2008 7:58 AM
To: [email protected]
Subject: RE: [flexcoders] Saving Typed Objects with AIR

 

Nick,

 

When you de-serialze your object you can cast it to the type you want.

 

Jeff

        -----Original Message-----
        From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Nick Collins
        Sent: Wednesday, March 26, 2008 9:34 AM
        To: flexcoders
        Subject: [flexcoders] Saving Typed Objects with AIR

        I'm trying to use the AIR file libraries to write an
actionscript object and it saves it just fine but it saves it as just a
type of Object. Is there a way where I can save the actionscript
objects, yet maintain their typing?
        
        

 

Reply via email to