UPDATE: I've uploaded the Actionscript code here:
I dare someone to make sense of it
I always play connect 4 in class at school when I'm bored. I'm actually quite good at it
So one day I was playing a friend, and I we argued who would draw up the grid on the paper. I ended up doing it, but then I had an awesome idea. We have our own kind of connect 4 game. Instead of playing first-to-get-a-row-wins kinda game, we actually play until the grid is filled up, and tally our rows. The awesome idea was - make one in Flash!
I had the basic idea layed out in my mind, but when it came to working out if a row had occured, it was quite complex. Although, I had already promised my friends I would finish it, so I was determined to get it working.
The basic idea behind working out rows is this - convert the multi-dimensional array of blocks (rows/cols) into a flat array. Then, I worked out the patterns in which rows would occur: horizontal lines would happen with an increment of +1, vertical would be +col, and diagonals would be +col+1 or +col-1 depending on the way it went.
However it wasn't completely there, I still had the errors of rows happening across sides. I fixed that by determining blocks that were row ends, and row starts. If a row end was in a row AND a row start, then the row would be false. If only one of them occured, then it was right.Total for loops: 18
This is just version 1, I will be adding more features later EDIT: There is a bug with diagonal rows. Apparently they still work across sides... somehow.