2 Replies Latest reply on Jan 18, 2007 11:39 PM by Camus Miu

    Cloning an instance of a class

    Camus Miu
      I found the following sharing on cloning a class from Benz's web site.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      private function initApp():void
      registerClassAlias("de.benz.something", Test);
      var t:Test=new Test();
      var newObj:Object=CommonFunc.clone(t);
      out.text+=typeof newObj;
      <mx:TextArea id="out" left="15" top="15" right="15" bottom="15"/>

      Anyway, I found that the clone is not really a class... the typeof traced is an Object
      so is the only way to clone a class is set up a public function in the class and return a new Class() with all the variables copied?