sendObject()

Availability:

Flash Player 7, 8
SmartFoxServer Lite / Basic / Pro

Usage:

smartFox.sendObject(obj:Object, roomId:Number)

Description:

Sends an Actionscript object to the other users in the room.
Can be usefull for sending complex/nested data structures to clients, like a game move or a game status change.

Supported datatypes are: Strings, Booleans, Numbers, Arrays, Objects

Parameters:

obj   An object containing all data that you need to send. The Object can contain other objects, arrays etc...
roomId   (optional) the Id of the target room. By default SmartFoxServer uses the id of the current room.
You may want to use this extra parameters if you're sending the object in a room that is different from the one you're currently in

Returns:

Fires the onObjectReceived event

Example:

Example #1
A simple object with primitive data is sent to the other clients.

move:Object = {}
move.x = 150
move.y = 250
move.speed = 8

smartFox.sendObject(move)

Example #2
An object with two arrays of items is being sent to the other clients.

itemsFound:Object = {}
itemsFound.jewels = ["necklace", "ring"]
itemsFound.weapons = ["sword", "sledgehammer"]

smartFox.sendObject(itemsFound)

See also:

onObjectReceived