Flash / Flex / ActionScript/XML/copy

Материал из Web эксперт
Перейти к: навигация, поиск

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);
    }
  }
}