# Nested for loop help

**URL:** <https://forum.kirupa.com/t/nested-for-loop-help/322576>\
**Category:** Uncategorized\
**Created:** [May 25, 2011, 9:47pm UTC](https://forum.kirupa.com/t/nested-for-loop-help/322576 "2011-05-25T21:47:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geHuC](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@geHuC](https://forum.kirupa.com/u/geHuC)\
**Post date:** [May 25, 2011, 9:47pm UTC](https://forum.kirupa.com/t/nested-for-loop-help/322576/1 "2011-05-25T21:47:19Z")

</div>

First of all hi to everybody glad to find such a vibrant AS forum (-:  
I’m not sure if i can explain what i want to do very well but i’ll try my hardest so please bear with me 🙂 So i’m running a simple nested for loop (code below) that when you go over a tile makes it change its color, so far so good but i also want to make it so that when you go over a tile you can then continue only on the tiles connected to it and not on every other tile and for the life of me i can’t seem to figure out how to do it :ne:  
the for loop is as follows

```auto
for (var colum = 0; colum < field_h; colum++)
			{
				for (var row = 0; row < field_w; row++)
				{
					box = new box_mc();
					box.gotoAndStop(1);
					box.y = box.width * row;
					box.x = box.height * colum;
					box.rownumber = row;
					box.columnumber = colum;
					box.buttonMode = true;
					box.addEventListener(MouseEvent.MOUSE_OVER, clickedBox);
					container.addChild(box);
				}
			}

```

and here is the clickedBox function

```auto
{
			e.currentTarget.gotoAndStop(2);
			e.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER, clickedBox);
			e.currentTarget.buttonMode = false;
			trace("row:"+e.currentTarget.rownumber +" colum:"+ e.currentTarget.columnumber);
		}

```

i think i should be able to do it using arrays but i can’t seem to understand how after the tiles are placed and the array updated accordingly to update the tiles with the new array value (enter frame event ? )

Thx to all in advance and a virtual beer to everyone :beer2:
