I checked my smart fox log files and I found the following error logged so many times in a room extension:
Code: Select all
INFO | jvm 1 | 2011/11/26 00:20:39 | 00:20:38.969 - [ WARNING ] > Error in extension [ xt31.as ]: TypeError: Cannot call method "getId" of null (my_ext.as#1965) Internal: 388 -- Line number: 388 in file: my_ext.as
Here is a part of my extension focussed at showing the variable "room" that becomes null:
Code: Select all
var room;
function init()
{
room = _server.getCurrentRoom();
}
function handleInternalEvent(e)
{
if(e.name == "userExit" || e.name == "userLost")
{
if (e.oldPlayerIndex > -1)
{
var res = {};
res.rm = room.getId();
...
}
}
}
The extension is a room extension.
The question: what could set the variable "room" to null?
assuming the left player is the last one in the room and the room is destroying, I think the vaiable "room" should still be valid till after the function call is done, no?