0 Replies Latest reply on Apr 26, 2008 2:08 PM by _peabulls_

    Object.constructor property

    _peabulls_
      <definition from ActionScript 2.0 Language Reference>
      ...constructor (Object.constructor property) ... Reference to the constructor function for a given object instance. The constructor property is automatically assigned to all objects when they are created using the constructor for the Object class ...

      //--- --- - - -

      i thought i understood this until i started doing some multiple level inheritance ..

      imagine three classes:
      -- class Object . . . (top level class)
      -- class ParentClass . . . (implicitly inherits from Object)
      -- class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)

      and three objects:
      -- var obj:Object . . . (an instance of Object)
      -- var parentObj:ParentClass . . . (an instance of ParentClass)
      -- var childObj:ChildClass . . . (an instance of ChildClass)

      what we get:
      obj.constructor == Object //-- as expected
      parentObj.constructor == ParentClass //-- as expected
      childObj.constructor == ParentClass //-- i would have thought it would be == ChildClass

      //--- --- - - -

      furthermore .. if i change my class definitions to be a bit less ambiguous:
      class Object . . . (top level class)
      class ParentClass extends Object . . . ( explicitly inherits from Object)
      class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)

      what we get:
      obj.constructor == Object
      parentObj.constructor == Object
      childObj.constructor == Object

      //--- --- - - -

      if this is the intended functionality of the constructor property i'm not sure i understand what its purpose is .. or am i completely misunderstanding something here .. if anyone has any answers i would be happy to hear them

      also .. feel free to ask for clarification (if i was unclear) or more complete code samples.