One interesting that I have found is the [Transient] metadata . What it does?
It instructs Flex not to serialize the object member (variable/function) when you do a serialize/deserialize of an object.
Here is a quick more in detail code
public class Test { private var x: int; private var y: int; public function get xval():int { return x*x; } public function set xval(value:int) { x= x*y; } public function set yval(value:int) { y=value + 1; } }
If you try to serialize and deserialize an instance of this class you would see that the values for x,y are different before and after. Why?
Well it seems that in the deserialization process all the values are extracted (x,y,xval and yval) and the getters/setters are executed. How to solve this problem? Simpl: use the [Transient] tag:
[Transient] public function get xval():int
When the object will be serialized the value for the xval will not be present and the getter/setter will not be executed.
The [Transient] metadata tag is not very well documented in Flex 2 or 2.0.1. If you look in some of the LiveCycle Data Services documentation you can see mentions of it, but there isn’t a dedicated page on the subject. In the beta Flex 3 documentation, [Transient] is finally explained. There is also some documentation gathered on The Flex Non-Docs weblog.
The [Transient] metadata tag can be used for classes that need to be on the server but also for other classes (when doing deep copies of them - I will write another post about object deep copy later - Here).
So the summary:
using [Transient] on a property removes that property from the AMF packet during serialization
Thanks to Darron Schall where I first saw the [Transient] metadata tag
Tags: amf, Flex 2, transient
This post was written by Virgil Cristea
Views: 995



















[...] if this is a nice and very effective method it has one flaw: it does not work with BitmapData. But here is a workaround [...]
as those standard getter are called to fill the properties of the copy, you need to provide them. or, alternativly you could also make the properties public, which is not a good way i guess.
took me some time to discover…