# Duplicate Background Tutorial

**URL:** <https://forum.kirupa.com/t/duplicate-background-tutorial/213420>\
**Category:** flash\
**Created:** [January 19, 2007, 12:25pm UTC](https://forum.kirupa.com/t/duplicate-background-tutorial/213420 "2007-01-19T12:25:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdx05](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@pdx05](https://forum.kirupa.com/u/pdx05)\
**Post date:** [January 19, 2007, 12:25pm UTC](https://forum.kirupa.com/t/duplicate-background-tutorial/213420/1 "2007-01-19T12:25:42Z")

</div>

Hey there,  
I’m trying to fill a movieclip with a seamless pattern, so in essense its pretty much the same as Kirupa’s Duplicate Background tutorial. I’m having trouble converting the AS from filling the background to filling a movieclip

Here’s the original code:  
[AS]tileBG = function () {  
tile\_width = 34;  
tile\_height = 34;  
//  
x\_max = Math.round(Stage.width/tile\_width);  
y\_max = Math.round(Stage.height/tile\_height);  
trace(x\_max);  
trace(y\_max);  
for (x=0; x\<=x\_max; x++) {  
for (y=0; y\<=y\_max; y++) {  
bg = \_root.attachMovie(“square”, “bg”+x+y, this.getNextHighestDepth());  
bg.\_x = tile\_width_x;  
bg.\_y = tile\_height_y;  
}  
}  
};  
tileBG();[/AS]

I’ve tried replacing \_root with the name of my clip, but that didn’t seem to do the trick, if anyone can point me in the right direction I’d appreciate it 🙂

J.
