Package | com.smartfoxserver.v2.requests |
Class | public class SetUserVariablesRequest |
Inheritance | SetUserVariablesRequest com.smartfoxserver.v2.requests.BaseRequest |
When a User Variable is set, the userVariablesUpdate event is dispatched to all the users in all the Rooms joined by the current user, including himself.
NOTE: the userVariablesUpdate event is dispatched to users in a specific Room only if it is configured to allow this event (see the RoomSettings.permissions parameter).
See also
Method | Defined By | ||
---|---|---|---|
SetUserVariablesRequest(userVariables:Array)
Creates a new SetUserVariablesRequest instance. | SetUserVariablesRequest |
SetUserVariablesRequest | () | Constructor |
public function SetUserVariablesRequest(userVariables:Array)
Creates a new SetUserVariablesRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
ParametersuserVariables:Array — A list of UserVariable objects representing the User Variables to be set.
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.USER_VARIABLES_UPDATE, onUserVarsUpdate); // Create some User Variables var userVars:Array = []; userVars.push(new SFSUserVariable("avatarType", "SwedishCook")); userVars.push(new SFSUserVariable("country", "Sweden")); userVars.push(new SFSUserVariable("x", 10)); userVars.push(new SFSUserVariable("y", 5)); sfs.send(new SetUserVariablesRequest(userVars)); } private function onUserVarsUpdate(evt:SFSEvent):void { var changedVars:Array = evt.params.changedVars as Array; var user:User = evt.params.user as User; // Check if the user changed his x and y user variables if (changedVars.indexOf("x") != -1 || changedVars.indexOf("y") != -1) { // Move the user avatar to a new position ... } }