Managing remaining lines

When a line is removed, probably there are some tetrominoes above it, just like in the previous picture. Obviously you can't leave the game field as is, but you have to make the above pieces fall down to fill the removed lines.

The idea: Check all pieces above the removed line and move them down to fill the gap left by the removed line.

The development: We can do it by simply moving down one tile, all tetrominoes pieces above the line we just deleted, and updating fieldArray array consequently.

Change checkForLines function this way:

private function checkForLines():void { for (var i:int=0; i<20; i++) { if (fieldArray[i].indexOf(0)==-1) { for (var j:int=0; j<10; j++) { fieldArray[i][j]=0; removeChild(getChildByName("r"+i+"c"+j)); ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.