# Replacing movieclip in grid

**URL:** https://forum.kirupa.com/t/replacing-movieclip-in-grid/186690
**Category:** flash
**Created:** [April 23, 2006, 6:26pm UTC](https://forum.kirupa.com/t/replacing-movieclip-in-grid/186690 "2006-04-23T18:26:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Peterhead\_Dave](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@Peterhead\_Dave](https://forum.kirupa.com/u/Peterhead_Dave)
#### Post date: [April 23, 2006, 6:26pm UTC](https://forum.kirupa.com/t/replacing-movieclip-in-grid/186690/1 "2006-04-23T18:26:35Z")

</div>

I have the following code, which takes a movieclip, square, and duplicates it to square0, square1 etc etc…

```auto

xgridlines = 10;
ygridlines = 10;
distance = 60;
setProperty ("square", _visible, false);
k = 0;
 
for (j=0; j<=xgridlines; j++) { 
 for (i=0; i<=ygridlines; i++) { 
duplicateMovieClip ("square", "square"+k, k);
setProperty ("square"+k, _x, distance*i);
setProperty ("square"+k, _y, distance*j);
k++; 
 } 
} 

```

What I want to do is click on one of the squares, and replace the white square with an image loaded from an array. Can anyone help?

I tried putting an onClipEvent(mouseDown) handler into the loop, but it threw up an error.

Thanks,  
Dave
