Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex Air: Read "ActionScript object" from file then cast?

It is quite simple to do it, you write the object down to file, then you read it:

  • http://corlan.org/2008/09/02/storing-data-locally-in-air/
  • http://cookbooks.adobe.com/post_Storing_ActionScript_Objects_in_the_Encrypted_Loca-10563.html

My questions are

  1. why when we put [RemoteClass(alias="foo.Bar")] into VO, it can be cast automatically (otherwise the type of the deserialized object is Generic Object with correct properties data inside it)?
  2. Is there another way to achieve it without RemoteClass tag? (Using metadata tag is preference)

Thanks

like image 416
Phung D. An Avatar asked May 24 '26 20:05

Phung D. An


1 Answers

  1. The answer is in the page you linked to:

    Note that the alias is a key that is stored with the class instance and links the class definition with the specific object that is stored in the ByteArray when an instance of that object is serialized. This key can be any unique string identifying this class, but convention is to use the fully normalized package and class name.

    That's why you get a generic object if you omit the alias - the deserialization method does not know what to do with the data, unless you specify to which class the values should be mapped.

  2. Yes, there is: registerClassAlias() does the same thing. But the metadata tag is much prettier to read ;)

like image 136
weltraumpirat Avatar answered May 28 '26 12:05

weltraumpirat