copy() method creates a duplicate of the original XML object so that it can be passed by value rather than reference. : copy « XML « Flash / Flex / ActionScript






copy() method creates a duplicate of the original XML object so that it can be passed by value rather than reference.

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var template:XML = <person><name><first /><last /></name></person>;
        var me:XML = template.copy();
        me.name.first = "Mims";
        me.name.last = "Wright";
        trace(template);
        
        trace(me);
    }
  }
}

        








Related examples in the same category