createRoom()

Availability:

Flash Player 7, 8
SmartFoxServer Lite / Basic / Pro

Usage:

smartFox.createRoom(roomObj:Object, roomId:Number)

Description:

Dynamically create a new room in the current zone.
The roomId parameter is optional and only needed for advanced tasks, when using multiple room at the same time.

Parameters:

An object with the following properties:

name   the room name
password   a password for the room (optional)
maxUsers   the max. number of users for that room
maxSpectators   the max. number of spectator slots (only for game rooms )
isGame     a boolean, true if the game is a game room
exitCurrentRoom   a boolean value. It can be used when creating a new game room.
By default when a new game rooms is launched, its creator is auto-joined inside the room leaving the one he was in before. If you don't want to leave the old room you should set this property to false.
uCount   a boolean, indicating if the new room will receive the uCount update messages.
The uCount messages are updates about the number of users in each room of the zone. If you're not handling them in the current room it is reccomended to turn it off.
vars   an array of room variables (see below)
extension   an optional object. Specifies which extension should be dynamically attached to the room.
The extension must be a Room-level extension.

The object should contain the following properties:

name   the name used to reference the extension
script   the file name of the extension script (.as for Actionscript, .class for java)
The file name is relative to the root of the extension folder (sfsExtensions/ for AS, javaExtensions/ for java)

A Room can be initialized with any number of Room Variables. The variables parameter is an array of objects with these properties:

name   variable name
val   variable value
priv   boolean, true if the variable is private
persistent   boolean, true if the variable is persistent

Returns:

Nothing.

Example:

var room:Object = new Object

room.name = "The Cave"
room.isGame = true
room.maxUsers = 15

var variables:Array = new Array()
variables.push( {name:"ogres", val:5, priv:true} )
variables.push( {name:"skeletons", val:4} )

room.vars = variables

smartFox.createRoom(room)

See also:

onRoomAdded(), onCreateRoomError()