Determining a cell value (if any)

We are working behind the scenes, so we need to add a function to return the value of a cell, or -1 if it does not exist, just like we did during the creation of Minesweeper.

private function cellValue(row:uint,col:uint):int {
if (gameField[row]==undefined||gameField[row][col]==undefined) {
return -1;
} else {
return gameField[row][col];

It will come in hand later, moreover it was developed at no cost since it has already been created and tested during the making of Minesweeper. Do you understand the importance of having little functions to use again and again?


public functions can be accessed by all classes which attempt to use them.

break stops processing a loop.

Now you have everything you need to determine ...

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.