problem with SpriteObj.addChild(TextfieldObj) inside a loop

Hi Guys,

Does anyone have any idea why this code displays all of the textfields on top of each other? For some reason the textfield objects refuse to inherit the position of the outer sprites that they are added to.

The square sprites are tiled vertically as intended, by increasing the value of buttonOffset on each pass of the loop.

if anyone is willing to test the code inside the flash ide, I would appreciate it, just add this as the document class of an empty .FLA

Thanks!



package {

    import flash.display.*;
    import flash.text.TextField;
        
    public class main extends Sprite {
                
        public function main():void {
            
            var data:Array = ['test1','test2','test3','test4','test5'];
            var contentHolderClip:MovieClip = new MovieClip();
            var buttonOffset:int = 0;            
            
            for(var i:int=0;i<data.length;i++) {
             
                var square:Sprite = new Sprite();             
                square.graphics.lineStyle(1,0x000000);
                square.graphics.beginFill(0xfefefefe);
                square.graphics.drawRect(0,buttonOffset,130,20);
                square.graphics.endFill();
            
                var navText:TextField = new TextField();                                        
                navText.text = data*;

                contentHolderClip.addChild(square);
                square.addChild(navText);

                buttonOffset += 21; 
                
            }
            
            addChild(contentHolderClip);
            
        };
              
    }

};