# AS3 - This broke my brain, help!

**URL:** https://forum.kirupa.com/t/as3-this-broke-my-brain-help/304489
**Category:** flash
**Created:** [February 8, 2010, 10:01pm UTC](https://forum.kirupa.com/t/as3-this-broke-my-brain-help/304489 "2010-02-08T22:01:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![makzumi](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@makzumi](https://forum.kirupa.com/u/makzumi)
#### Post date: [February 8, 2010, 10:01pm UTC](https://forum.kirupa.com/t/as3-this-broke-my-brain-help/304489/1 "2010-02-08T22:01:57Z")

</div>

Hi Guys,

I’m stuck with some game logic and just cant figure it out, can someone please help???

Scenario:

The game consists of matching pieces of the same type and removing them from screen, sort of like a “Match 3” game, but instead of 3 you can match more than 3 of the pieces as long as they connect and of the same type.

The game grid is saved in an array which stores row and column position.  
I need to go through the array and verify if the pieces are together and if more than 3 are connected then they will be removed from the screen.

Examples:

X’s should be removed

0 0 0 0 0 0 0  
0 0 0 0 0 0 0  
0 **X** 0 0 0 0 0  
0 **X** 0 0 0 0 0  
0 **X X X X** 0 0

* * *

0 0 0 0 0 0 0  
0 0 0 0 0 0 0  
0 **X X** 0 0 0 0  
0 0 **X X X** 0 0  
0 0 0 0 0 0 0

I have tried several different ways but I’m burned out, cant think no more

Attached is the test FLA I’m using to figure out the logic.

Usage: Compile and the click on the squares, after the 4th in a row the pieces return to their original state.  
But if you have 3 in a row, and then 2 in a row on another column or row the 5 will disappear and only when connected they should disappear.

I hope I’m clear,

Please help, I’m desperate!

Thanks!!!
