Player.IO

Build fun, powerful & scalable online and mobile games with the reliable backend your users expect

Sign Up | Sign In

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

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
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 (message:playerio:Message):void

Sends a message to the server

connected

Returns the connection's connected status

Return Value

addDisconnectHandler

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

Function handler
Callback to execute if disconnected from the server.

addMessageHandler

Add listener for messages of a specified type

Arguments

String type
String that defines what type to listen to. If sat to " the listener will listen to all message types
Function handler
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

createMessage

Creates a Message instance

Arguments

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

Return Value

playerio:Message

disconnect

Disconnects from the server

removeDisconnectHandler

Removes a handler previously attached with addDisconnectHandler

Arguments

Function handler
Callback we wish to remove the listener for.

removeMessageHandler

Removes a message handler previously attached with addMessageHandler

Arguments

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

send

Quick way to send messages to the server

Arguments

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

sendMessage

Sends a message to the server

Arguments

playerio:Message message
Message to send to the server