# Problem with tiled background. Urgent help please!

**URL:** <https://forum.kirupa.com/t/problem-with-tiled-background-urgent-help-please/225206>\
**Category:** flash\
**Created:** [May 9, 2007, 5:20pm UTC](https://forum.kirupa.com/t/problem-with-tiled-background-urgent-help-please/225206 "2007-05-09T17:20:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrinceTaj](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@PrinceTaj](https://forum.kirupa.com/u/PrinceTaj)\
**Post date:** [May 9, 2007, 5:20pm UTC](https://forum.kirupa.com/t/problem-with-tiled-background-urgent-help-please/225206/1 "2007-05-09T17:20:31Z")

</div>

Hi guys!

I’m trying to tile the background of a movieClip with a set of small squares, called grid. However, the script only attaches on instance of grid. I don’t understand why this is. Below is my code exert:

```auto

function tileGrid() { 

      grid_width = 20;
    grid_height = 20;
    //
    x_max = Math.round(canvas_mc._width/grid_width);
    y_max = Math.round(canvas_mc._height/grid_height);
   
    for (x=0; x<x_max; x++)
    {
        for (y=0; y<y_max; y++)
        {
            bg = this.canvas_mc.attachMovie("grid", "gd"+x+y,
                100+x*y);
            bg.duplicateMovieClip({_x: grid_width*x, _y: grid_width*y});
     
        }// End of inner loop
    }// End of outer loop
}

tileGrid();

```

If anybody could explain a reason for this, or remedy my code, I would be very grateful.

Many thanks

TAJ

P.S. Please find attached a copy of the source.
