ForumsProgramming ForumPlatform Game With PlayerIO (As3)

2 9522
mightybob
offline
mightybob
360 posts
Peasant

Well I got an example up and running from PlayerIO's website, people realtime drag around the letters and crap like that.

But I can't wrap my head around how this works, I was able to get it working with help of a tutorial but unfortunately their tutorials only tell you how to do this in very precise circumstances and doesn't actually teach me how to use it.

Here's the code:

package {
import flash.display.MovieClip
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.StageScaleMode
import flash.display.StageAlign
import flash.events.Event
import playerio.*
public class FridgeMagnets extends MovieClip{
private var connection:Connection;
private var texts:Array = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!?\\/()-:.".split("&quot
private var cursors:Object = []
private var letters:Array = [];
private var myId:int
private var offsetWidth:Number = 0;
private var offsetHeight:Number = 0;
private var lcOffset:Number =0
private var colors:Array = [
0x333399,
0x339933,
0x993333,
0x999933,
0x339999,
0x993399
]

function FridgeMagnets(){
stop();
PlayerIO.connect(
stage, //Referance to stage
"(removed my ID for security crap)", //Game id (Get your own at playerio.com. 1: Create user, 2:Goto admin pannel, 3:Create game, 4: Copy game id inside the "&quot
&quotublic", //Connection id, default is public
"GuestUser", //Username
"", //User auth. Can be left blank if authentication is disabled on connection
null, //Current PartnerPay partner.
handleConnect, //Function executed on successful connect
handleError //Function executed if we recive an error
);

stage.scaleMode = StageScaleMode.NO_SCALE
stage.align = StageAlign.TOP_LEFT
}

private function handleConnect(client:Client):void{
trace("Sucessfully connected to player.io"

//Set developmentsever (Comment out to connect to your server online)

//Create pr join the room test
client.multiplayer.createJoinRoom(
"testGame", //Room id. If set to null a random roomid is used
"FridgeMagnets", //The game type started on the server
true, //Should the room be visible in the lobby?
{}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server
{}, //User join data
handleJoin, //Function executed on successful joining of the room
handleError //Function executed if we got a join error
);
}


private function handleJoin(connection:Connection):void{
trace("Sucessfully connected to the multiplayer server"
gotoAndStop(2);

//Handle init message
connection.addMessageHandler("init", function(m:Message, myid:int){
//Set my id so we know who we are
myId = myid

//Create letters
for( var a:int=1;a

  • 2 Replies
weirdlike
offline
weirdlike
1,299 posts
Prince

i would make a copy of the class then slim down on the code to understand each function

package {
import flash.display.*;
import flash.events*;
import playerio.*;

public class FridgeMagnets extends MovieClip
{
private var connection:Connection;

function FridgeMagnets()
{
stop();
PlayerIO.connect(stage, "(removed my ID for security crap)", &quotublic", "GuestUser", "" /*User auth.*/, null, handleConnect, handleError );
}

private function handleConnect(client:Client):void
{
trace("Sucessfully connected to player.io"
}
private function handleError(client:Client):void
{
trace("Failed connection to player.io"
}
}
}

mightybob
offline
mightybob
360 posts
Peasant

okay, thanks

Showing 1-2 of 2