onSpectatorSwitched()

Availability:

Flash Player 6.0
SmartFoxServer Basic / Pro

Usage:

smartFox.onSpectatorSwitched(success, newId, roomObj)

Description:

The event is fired in response to a switchSpectator() request. The request to turn a spectator into a player may fail if another user did the same before your request and there was only one player slot available.
All spectators have their playerId property set to -1 when you become a player your playerId will get a number > 0, representing the player number.
For example in a game room for 3 players your Id can be any number between 1,2,3. These values are assigned by the server, based on the order in which the players joined.

Parameters:

success   True if the spectator user was turned into a player in a game room, otherwise will return False
newId   The playerId assigned by the server
roomObj   the object representing the room where the switch occurred

Check the Room Class for more info on the objects returned.

Returns:

nothing

Example:

smartFox.onSpectatorSwitched = function(success, newId, roomObj)
{
	if (success)
	{
		trace("Great! Now I am player #" + newId)
	}
	else
	{
		trace("The attempt to switch as a player failed.")
	}
}

See also: