Hi all,

has anyone experienced this problem with getChildAt() returning null for
some of its children?

I have some movieclips which are rather complex animations with some nested
stuff in them. My problem is that I have to make sure the nested movieclips
(which have 2 frames each) stay stopped in either the first or second frame,
at any one time.
I know you can't mess around with a movieclip's animation before it's even
appeared on the screen, so everything I'm doing happens AFTER it was added
to the stage.

What I try to do is simple: at each frame of the animation (I have an
enterFrame listener on it), I run through every single of its children and
call either gotoAndStop(1) or gotoAndStop(2) as needed.
This was supposed to work, if I hadn't run into this strange issue with null
children... Below is a sample code I used to check the current frame of each
of the animation's children. Surprisingly, some of them are listed as being
null, even though they are counted as valid children (from the numChildren
property):

for(var j:int = 0; j < mc.numChildren; j++) {
  if(mc.getChildAt(j) is Shape) {
     // ignoring Shapes, as they have no frames
     continue;
  }

  var current:MovieClip = MovieClip(mc.getChildAt(j));
  if(current != null) {
      trace(" -- " + current + ": " + current.currentFrame + "[" +
current.totalFrames + "]");
  }
  else {
      trace(" -- " + mc.getChildAt(j)); // always prints null
  }
}


I'm really confused here. Is this some kind of optimization Flash does with
its animations? I have the same behavior either with Flash 9 Alpha or Flash
CS3.

--
Frederico Ferro Schuh
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to