Problem with 2D array and Null values

I’m sure this is a really simple question for anyone who’s come across it before.
I have a grid of objects. I’m comparing properties of objects above, below, left and right of an object in the grid when clicked.

This is fine until I click on an object on one of the sides of the grid, then it’s returning null - like you’d expect.

I thought i’d solved the problem like this…

right = GlobalVars.allBlocks[row][col + 1];
if (right == null) { right = GlobalVars.empty; }
left = GlobalVars.allBlocks[row][col - 1];
if (left == null) { left = GlobalVars.empty; }
above = GlobalVars.allBlocks[row - 1][col];
if (above == null) { above = GlobalVars.empty; }
below = GlobalVars.allBlocks[row + 1][col];
if (below == null) { below = GlobalVars.empty; }

However this only works with the “left” and “right” MovieClip references, but the “top” and “bottom” throw a TypeError: Error #1010: A term is undefined and has no properties. - if i try to catch the error it throws a TypeError: Error #1009!

Why would the left and right work fine, but not the top and bottom?!

Any ideas?

Andy