Cloning Objects In Flex

Cloning Objects In Flex

When cloning objects in PHP you simply do:
$newObject = clone $oldObject;
You can do the same thing in Flex:
import mx.utils.ObjectUtil;

var newObject:Object = ObjectUtil.clone(oldObject);
However, this function is only designed to clone data objects. Meaning only objects that holds pure data. It will not work for objects like UIComponent. For the later instance, you will need to create a subclass of the component and implement a clone method instead, or you can try a class written on  ADM Blog for cloning none data objects.


Leave a Reply

Your email address will not be published. Required fields are marked *

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!