1 Reply Latest reply on May 9, 2007 6:33 AM by parallaxed

    Need some help

    y.muny
      I'm Muny. Now i try to make a small project like i did with Flash before. With flash i used Duplication method to copy object. but i don't know about Flex method to copy object?
      could you help me how to write script to duplicate object?
        • 1. Re: Need some help
          parallaxed
          Extend the class you want to be able to copy, adding a "clone" method or similar.

          public class CantCopyThis
          {
          public var someVal:int
          public function CantCopyThis(someVal:int)
          {
          this.someVal = someVal;
          }

          }

          public class CanCopyThis extends CantCopyThis
          {
          public function CanCopyThis(someVal:int)
          {
          super(someVal);
          }
          public function clone():CanCopyThis
          {
          // return an instance of CanCopyThis, with the current instance properties.
          return new CanCopyThis(this.someVal);
          }
          }

          You may also want to look into the ClassFactory.