Tilebased game - brick collision

Hi,

I’m workin on a tilebased game, with some black “draggable” bricks (when mousepointer hit the tile it goes to next frame, which is black). Now I want to check if the bricks are connected to each other. Also with some kind of counter, that displays which tiles that are connected.

I can’t use the hitTest function since the bricks will not touch each other.

Do I need to loop through and check each tile in 8 directions, or are there any better way for this?

Here’s a screenshot what I’m trying to do:
http://student.educ.umu.se/~thslon01/game/collisions2.html

The tiles are generated dynamicly.

I use AS 2 and Flash 8.

Thankful for some advise.

Regards,
S-fish