I agree, this is a difficult task. ObjectUtil.clone() works but it does not retain the class definitions of any of the properties/classes within the custom object being copied. Unfortunately I don't believe you can typecast these plain objects back to their original types either, unless you enforce strict data typing.
1 person found this helpful
You do can clone an array collection and still keeping the data types same...check the below line of code..
cloneArrayCollection = ObjectUtil.copy(originalArrayCollection) as ArrayCollection;
The above line of code will clone the originalArrayCollection and copy it to the cloneArrayCollection while retaining the datatypes.
If this post answers your question or helps, please kindly mark it as such.
Hi, I tried to do as you suggested:
var m:BudgetGridModel = ObjectUtil.copy(model) as BudgetGridModel;
However what I get back from the copy is null.
Is the data type of your model is BudgetGridModel or an ArrayCollection..???
What is the structure of your model variable...
Is it the following way...?
model = ArrayCollection..
If your model is an ArrayCollection of BudgetGridModel objects...you can simply use the same way I posted earliar...
var m:ArrayCollection = ObjectUtil.copy(model) as ArrayCollection;
now m will be your new copy of model which is an arraycollection of BudgetGridModel objects..