Page 1 of 1

onUserVariablesUpdate returning wrong values

Posted: 22 Nov 2007, 01:54
by Savij
Hello,

I am using FlexBuilder 2 (AS3) with SmartFox Server.

I am getting the wrong values back from SFSEvent in onUserVariablesUpdate . I created an array called userVars and set the values, then called sfs.setUserVariables(userVars); This fires onUserVariablesUpdate().

I see the xml come back from the server correctly as follows:

[ RECEIVED ]: <msg t='sys'><body action='uVarsUpdate' r='1'>
<user id='20' /><vars><var n='NewX' t='n'><![CDATA[589]]></var>
<var n='UserID' t='n'><![CDATA[20]]></var><var n='NewY' t='n'>
<![CDATA[145]]></var></vars></body></msg>, (len: 212)

However when I retrieve SFSEvent in onUserVariablesUpdate(evt:SFSEvent) I get the following:

changedVars = Array (@3c4a461)
[0] = "NewX"
[1] = "UserID"
[2] = "NewY"
length = 3
NewX = true
NewY = true
UserID = true

I dont understand why the values are true instead of the values I can see in the CDATA in the xml??? Is this a bug? Is it getting fixed in 1.6?

Thanks,

Jeff
P.S. Happy Thanksgiving to those that celebrate it.

Posted: 22 Nov 2007, 09:38
by Lapo
changedVars does not tell you the values of the variables, it just notifies which variables were changed. (hence the name)

In other words it helps to determine which values where changed in a certain User variables.
The actual values can be taken from the User object passed in the event.

from the docs:

Dispatched when a user updates his/her User Variables.
The params object contains the following parameters.

- user:User - the User object representing the user updating the variables.
- changedVars:Array - n associative array with the names of the changed variables as keys. You can also iterate through numeric indexes (0 to length) to get the names of the variables that changed.

p.s. = since this is not a bug I am moving the message in the general help section