Draw grid line with numbering in AS3

hi,

I have some problem with the grid line with numbering just like the graph paper with some numbering on the x & y axis. I have done with the grid in a container(UIComponent size 500 by 500, size can be change anytime). So my problem is that how to do I label the numbering on each grid line on both x & y axis like 10, 20, 30 and so on to the end on x & y axis. I try textfield but the problem is I have to create another textfield for every grid line as the size of the container can change so I trying make dynamic as I don’t have to assign the numbering myself.




            private static const DisOriginX:Number = 200;
            private static const DisOriginY:Number = 300;

            public function gridline():void
            {
                var size:int = 15;
                var borderSize:int = 1;
                var rows:Number;
                var cols:Number;
                var r:int;
                var c:int;
                var shape:Sprite = new Sprite();
                var newLabelX:Number = 0;
                var i:int = 0;
                
                //draw grid line
                rows = Math.round(container.height / size);
                cols = Math.round(container.width / size);
                container.height = rows * size;
                container.width = cols * size;
                        
                for(c=0; c<cols; c++)
                {
                    for(r=0; r<rows; r++)
                    {
                        var toX:Number = c * size;
                        var toY:Number = r * size;
                        shape.graphics.lineStyle(borderSize);
                        shape.graphics.drawRect(toX, toY, size, size);
                        
                        t.text = (DisOriginX/10).toString();
                        
                        
                    }
                }
                
            
                container.addChild(t);
                container.addChild(shape);
                    
}