0 Replies Latest reply on Apr 25, 2007 11:29 AM by CrackWilding

    instantiating a class within a class

      I've got a package with 2 classes. The first, we'll call it C1, is being instantiated within the main body of code. In turn, it instantiates another class, C2.

      Problem is, the C2 instantiation is not happening. However, if I instantiate the class within the main code body, the instantiations within C1 work ok. A chopped down version of my code:

      // main.swf
      import stuff.*;

      var myC1:C1 = new C1();
      var myC2:C2 = new C2(); // remove this line and the line below stops functioning

      // C1.as
      class stuff.C1 {
      public function C1() {
      trace('C1 instantiated');
      var anotherC2 = new C2(); // this line doesn't work unless the line above is included

      // C2.as
      class stuff.C2 {
      public function C2() {
      trace('C2 instantiated');

      So if I take the classes out of the package it works also, so I'm guessing it has something to do with the way I'm importing the files maybe? I dunno. Any thoughts?