Forum ActionScript 3.0 I can't get other name.

Problems and discussions relating to ActionScript 3.0 here.

I can't get other name.

Postby simosc » January 7th, 2011, 5:58 pm

Hi all,
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()
simosc
 
Posts: 6
Joined: January 6th, 2011, 8:49 am

Re: I can't get other name.

Postby Benjaminsen » January 7th, 2011, 6:11 pm

the variable names is undefined. So flash casts an error when you try to access it.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: I can't get other name.

Postby simosc » January 7th, 2011, 6:31 pm

Why it is undefined?
If i change it with, for example, "User" + "1234213454" it show me the same error...
simosc
 
Posts: 6
Joined: January 6th, 2011, 8:49 am


Return to ActionScript 3.0



cron