Hello i have this method:
private function findConnectedNodes(node:Node):Array{
var test_node:Node;
var surrounding_nodes:Array = [];
for(var i:uint = 0;i <= nodes.length; i++){
test_node = this.nodes[i]; // contains an array of Node objects
if (test_node.row < node.row - 1 || test_node.row > node.row + 1) continue;
if (test_node.column < node.column - 1 || test_node.column > node.column + 1) continue;
surrounding_nodes.push(test_node)
}
return surrounding_nodes;
}
I am getting this error: Cannot access a property or method of a null object reference. This error is appearing on the if statement.
I think this is due to the test_node variable, as flex debug shows me that test_node is NULL. Not sure why this is, as you can clearly see I am assigning objects in the array to test_node.
If I change test_node = this.nodes[i]; to test_node = this.nodes[<enter a number>] the program works
i <= nodes.lengthShouldn’t it be
i < nodes.length? This way you’ll get null node on last step.