Anyway, here is the hello world class I made in my project.
- Code: Select all
public class HelloWorld
{
var gameID:String = "hello-world-7w0k9tvc0yxv303jmi7ug"
public function HelloWorld():void
{
//This connects us to our game server
PlayerIO.connect(
stage, //Room id. If set to null a random roomid is used
gameID, //The game type started on the server
"public", //Should the room be hidden from the lobby?
"GuestUser", //Room data.
"", //User join data
handleConnect, //Function executed on successful joining of the room
handleError //Function executed if we got a join error
);
}
// Called on successful connection
function handleConnect(client:Client)
{
trace("Connected to server")
//Connect to the local development server instead of Player.IO servers.
client.multiplayer.developmentServer = "127.0.0.1:8184";
//Makes us join or create the room "test"
client.multiplayer.createJoinRoom("test", "", false, {}, {}, handleJoin, handleError);
}
function handleJoin(connection:Connection):void
{
//Send "Hello" to the server
connection.send("Hello World");
//Listen for the "hello world" message and trace out when it arrives
connection.addMessageHandler("Hello World", function(m:Message) {trace(m.type);} )
}
function handleError(error:PlayerIOError)
{
trace("error");
}
}
However I get the following error when trying to call the class:
In main I am just calling HelloWorld();Main.as(22): col: 4 Error: Incorrect number of arguments. Expected 1.
Also (I assume it's unrelated) SimpleGameFS.as is throwing the following error:
playerio\SimpleGameFS.as(6): col: 41 Error: Interface GameFS was not found. internal class SimpleGameFS implements GameFS{
I'm assuming I'm missing something straightforward, or I've messed up somehow, I just can't see how it can be expecting an argument when none is defined in the constructor... Anyway, if somebody could please help out I'd be eternally grateful! Thanks in advance
edit: I'm an idiot, forgot to put "new" before HelloWorld();
Also, there was an error with the PlayerIO.connect function call in the tutorial, it should be:
- Code: Select all
PlayerIO.connect(
stage, //Room id. If set to null a random roomid is used
gameID, //The game type started on the server
"public", //Should the room be hidden from the lobby?
"GuestUser", //Room data.
"", //User join data
"", //PartnerID String that Identifies affiliate partner
handleConnect, //Function executed on successful joining of the room
handleError //Function executed if we got a join error
);
Just for future reference