0 Replies Latest reply on Jan 12, 2011 1:56 PM by Kainlan

    AS2.0 Class Initalization




      Having an issue where a child class when it's created the parent class isn't defined yet, and this is determined by flash at compile time the order the classes should be in. Example and how I know this is happening.


      class A
      public static var classATrace = trace("Class A defined!");


      class B extends A

      public static var classBTrace = trace("Class B defined!");


      Obviously this is simplified code, but when it runs in my code what prints is "Class B defined!" then "Class A defined!" so when class B is defined it's parent class doesn't exist so it fails to extend from it properly. The strange part is I can remove random code that's not even called from other classes it it'll fix the issue and cause "Class A Defined!" to trace before "Class B Defined!"


      So I was curious if anyway has had something similar like this happen, and if there's any suggestions on what to do to work around what seems to be a flash compiler issue (MTASC compiles the code fine)