PlayerIO

The fastest way to build online games without breaking a sweat.

ActionScript3 Reference

actionscript 3 Connection class informationClass Connection

Namespace: playerio
Language: ActionScript 3

Allows the client to connect to the Multiplayer servers

Properties

 
public
connected :Boolean [read-only]

Returns the connection's connected status

public
roomId :String

Methods

 
public
addDisconnectHandler (handler:Function):void

Listen to server disconnects. This method is only called if we are disconnected by the server. A call to connection.disconnect will not trigger this method.

public
addMessageHandler (type:String, handler:Function):void

Add listener for messages of a specified type

public
createMessage (type:String, ... args):playerio:Message

Creates a Message instance

public
disconnect ():void

Disconnects from the server

public static
encode (data:flash.utils:ByteArray):String

public
removeDisconnectHandler (handler:Function):void

Removes a handler previously attached with addDisconnectHandler

public
removeMessageHandler (type:String, handler:Function):void

Removes a message handler previously attached with addMessageHandler

public
send (type:String, ... args):void

Quick way to send messages to the server

public
sendMessage (m:playerio:Message):void

Sends a message to the server

Connection.connected

public
connected :Boolean [read-only]

Returns the connection's connected status

Connection.roomId

public
roomId :String

Connection.addDisconnectHandler

public
addDisconnectHandler (handler:Function):void

Listen to server disconnects. This method is only called if we are disconnected by the server. A call to connection.disconnect will not trigger this method.

Arguments

handler:Function
Callback to execute if disconnected from the server.

Connection.addMessageHandler

public
addMessageHandler (type:String, handler:Function):void

Add listener for messages of a specified type

Arguments

type:String
String that defines what type to listen to. If sat to " the listener will listen to all message types
handler:Function
Callback method executed when a message of the type specified is recived: function(m:Message):void{...} or function(m:Message, messageValye1:Type, messageValye1:Typ, ... ):void{...}

Example

Shows how to define a message listener

Example

Shows how to define a message listener with inline arguments

Connection.createMessage

public
createMessage (type:String, ... args):playerio:Message

Creates a Message instance

Arguments

type:String
The type of the message
... args
Data entries we should add to the message when we create it

Connection.disconnect

public
disconnect ():void

Disconnects from the server

Connection.encode

public static
encode (data:flash.utils:ByteArray):String

Arguments

data:flash.utils:ByteArray

Connection.removeDisconnectHandler

public
removeDisconnectHandler (handler:Function):void

Removes a handler previously attached with addDisconnectHandler

Arguments

handler:Function
Callback we wish to remove the listener for.

Connection.removeMessageHandler

public
removeMessageHandler (type:String, handler:Function):void

Removes a message handler previously attached with addMessageHandler

Arguments

type:String
String that defines what type we wish to stop listening to
handler:Function
Callback we wish to remove the listener for

Connection.send

public
send (type:String, ... args):void

Quick way to send messages to the server

Arguments

type:String
The type of the message we want to send
... args
Data entries that should be added to the message

Connection.sendMessage

public
sendMessage (m:playerio:Message):void

Sends a message to the server

Arguments

m:playerio:Message