2 Replies Latest reply on Nov 19, 2010 2:47 PM by MartinHviid

    What is the difference between instantiating a property with its definition, and in the constructor?

    JoshBeall

      Hi All,

       

      Consider the following two class definitions:

       

       

      class MyClass {
           public var collection:ArrayCollection = new ArrayCollection();
      }
      
      class MyClass2 {
           public var collection:ArrayCollection;
      
           public function MyClass2() {
                this.collection = new ArrayCollection();
           }
      }
      

       

       

      The first one is more concise and takes fewer lines of code.  Is there any disadvantage to it?

       

      Are there any differences in how the Flash Player will interpret this code once it's been compiled?  Or do they compile down to the same bytecode?

       

      Thanks!

       

        -Josh