Hi all.
I am generating dynamic menus from an xml file. When I create movie clip buttons inside a for loop I am adding these to a sprite so that I can add child to the stage and chage its position. when I come out of this loop the sprite.numChildren is coming out to be 0 where as inside the loop if I trace it its comes out fine here is the code.
var sprite:Sprite = new Sprite();
sprite.x = 50;
sprite.y = 50
// generating movieclip menus
for ( var i:int = 0; i < array.lenght;i++){
var menu:MenuClassMoiveClip = new MenuClassMovieClip();
menu.x = menu.width*i;
sprite.addChild(menu);
trace(sprite.numChildren); // gives 1,2,3 and so on depending on array lenght
}//
for (var j:int= 0; j < sprite.numChildren ; j++){
trace(sprite.numChildren); // nothing is traced even it does not enter into the for loop because sprite.numChildren is 0
}
Any help will be really appreciated
Thanks a bunch