I have some problem whith my multiplayer game.
Flash says to me:
- Code: Select all
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MyGame_fla::MainTimeline/MyGame_fla::frame2()
Where the Action script is:
- Code: Select all
stop()
//Connect and join the room
var connection:Connection;
var names:String = username.text;
var gameID:String = "xxxxxxxxxxxxxxx"
PlayerIO.connect(stage, gameID, "public", names ,"", handleConnect, function(){trace("connect error")} ); //This connects us to our game server
function handleConnect(client:Client){ // Called on successful connection
trace("Connected to server")
//client.multiplayer.developmentServer = "127.0.0.1:8184";
client.multiplayer.createJoinRoom("test", "upper", false, {}, {}, handleJoin, function(error){trace(error)} ); //Makes us join or create the room "test"
nextFrame();
}
//called when a user joins the room
function handleJoin(conn:Connection){
trace("joined")
connection = conn
//This will call gotMessage every time we receive any message
connection.addMessageHandler("*",gotMessage);
}
It works only if i change the var names to "User" + Math.floor(Math.random()*1000).toString()