# Draw grid line with numbering in AS3

**URL:** <https://forum.kirupa.com/t/draw-grid-line-with-numbering-in-as3/267450>\
**Category:** flash\
**Created:** [August 1, 2008, 7:03am UTC](https://forum.kirupa.com/t/draw-grid-line-with-numbering-in-as3/267450 "2008-08-01T07:03:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kleave](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kleave](https://forum.kirupa.com/u/kleave)\
**Post date:** [August 1, 2008, 7:03am UTC](https://forum.kirupa.com/t/draw-grid-line-with-numbering-in-as3/267450/1 "2008-08-01T07:03:32Z")

</div>

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.

```auto

            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);
                    
}

```
