1 Reply Latest reply on Jun 16, 2007 5:05 PM by kglad

    [AS3.0] MovieClip.Children not found after gotoAndStop()

    codetale Level 1
      is there anyone met this problem before?

      I have a MovieClip with linkageName MyClip
      this MovieClip contain 3 frames
      each frame contain 2 child MovieClip name childA, childB

      in AS2 i can create the MovieClip on the fly and control it with code below
      var mc = this.attachMovie("MyClip", "newClip", 0);
      mc.gotoAndStop(3)
      mc.childA.gotoAndStop(2)
      mc.childB.gotoAndStop(1)
      ...


      AS3.0 in FlashCS3 I set the linkage properties
      Class: MyClip
      Base class: flash.display.MovieClip

      import flash.display.MovieClip;
      public dynamic class MyClip extends MovieClip{
      public function MyClip(){
      this.gotoAndStop(3);
      this.childA.gotoAndStop(2);
      this.childB.gotoAndStop(1);
      }
      }

      // create clip somewhere
      var mc:MyClip = new MyClip();// error

      it raise error, because of cant found the childA and childB

      even if i have not create the MyClip.as, use Flash default generated class
      var mc = new MyClip();
      mc.gotoAndStop(2);
      mc.childA.gotoAndStop(2);// raise error also


      the error::
      TypeError: Error #1009: Cannot access a property or method of a null object reference.


      it work if i set a timer and call to mc.childA later few ENTER_FRAME later
      var mc = new MyClip();
      // set time out here and do later
      mc.childA.gotoAndStop(2);// it work!



      is there any idea to solve this problem without setting a "timer callback" and do after.
      i want to access the "children" immediately once the MovieClip created and the frame changed by gotoAndStop(#) call

      thankyou