Check grid for sets of 3 that add to 10, vertically and horizontally

Alright, so i am working on a little game here, and i’m having trouble checking the grid here.
let’s say i have a grid that’s 8x13, and each spot has a value below 11.

I want to check the grid in sets of 3 to see if the three spots laying vertically or horizontally are equal to 10 when added together. if so, remove them, and then shift all the values above it down to fill the gap.

Example:


...
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
8,0,0,0,0,0,0,0
1,0,4,7,6,2,5,2
1,0,3,1,5,2,7,10
8,9,4,5,3,2,5,6

there are 3 matches here. all the way to left vertically, we have either: 8,1,1, or 1,1,8. and on the bottom row: 5,3,2.

alright, so if its checking from the bottom, we remove 1,1,8, and we remove 5,3,2:


...
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,4,0,0,0,5,2
0,0,3,7,6,2,7,10
8,9,4,1,5,2,5,6

oh, now there is another set here before moving on and checking other rows, bottom row: 4,1,5. alright, so proceed to remove them:


...
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0
0,0,0,0,0,0,5,2
0,0,4,0,0,2,7,10
8,9,3,7,6,2,5,6

now the code should continue on and check the rest of the grid too…

Now, how do i do this with as3?