Try to set userVariables with:
var obj:Object = new Object();
obj.score = 123;
smartFox.setUserVariables(obj);
Also in code have:
smartFox.addEventListener(SFSEvent.onUserVariablesUpdate, onUserVarUpdate);
function onUserVarUpdate(evt:SFSEvent) {
var u:User = evt.params.user as User;
var userVars:Array = evt.params.changedVars;
}
After debug have in array userVars:
[0] = "score" /here need to be 123 ???? /
length = 1
score = true
Also:
u.getVariable("Score") not works. The only way to get use variables is with:
u.getVariables()[0]
userVariables not works for AS 3.0
Hi Lapo,
Of course I test with more that one client. In fact with 3-4 clients and I receive event onUserVariablesUpdate only in other clients . User wich set varialbe not receive this event and I make debug for other client . In fact first log in one user, after that user in debug mode, and then third user which set user variable 'score' . I'm read all documentation (for uservariables ) and also avatar chat and think make all correctly.
Of course I test with more that one client. In fact with 3-4 clients and I receive event onUserVariablesUpdate only in other clients . User wich set varialbe not receive this event and I make debug for other client . In fact first log in one user, after that user in debug mode, and then third user which set user variable 'score' . I'm read all documentation (for uservariables ) and also avatar chat and think make all correctly.
I see a problem here:
but you then try to retrieve the variable like this:
"score" != "Score"
Code: Select all
obj.score = 123; Code: Select all
u.getVariable("Score")I try with u.getVariable("Score") and with u.getVariable("score") and problem it's not in upper case because I debug what have in array userVars .
From debug mode:
--> [0] = "score"
--> length = 1
--> score = true
So array have only one element with value 'score' and not with value 123 which is correct. I think the problem is in the way that AS 3.0 present Array. In AS 3.0 not have named Array example
var u:Array = new Array();
u['score'] = 123; -- > It's not correct !!!
and is used Object instead of that.
var u:Object = new Object();
u['score'] = 123;
From debug mode:
--> [0] = "score"
--> length = 1
--> score = true
So array have only one element with value 'score' and not with value 123 which is correct. I think the problem is in the way that AS 3.0 present Array. In AS 3.0 not have named Array example
var u:Array = new Array();
u['score'] = 123; -- > It's not correct !!!
and is used Object instead of that.
var u:Object = new Object();
u['score'] = 123;
Code: Select all
var u:Array = new Array();
u['score'] = 123; -- > It's not correct !!! The compiler does not complain about that.
There's of course an ambiguity between associative arrays and "maps" or "dictionaries" created with plain Objects, but it's perfectly legal.
Back to the topic: we don't seem to be able to reproduce the problem.
We can send user variables from one client and receive them without problems.
A couple of suggestions:
1. we're using the latest API. Version 1.3.5
Are you using this version? Just use the getVersion() method to check
2. dump all the variables
This is the code we use to check the variables that are received by the other clients:
Code: Select all
function onUserVariablesUpdate(evt:SFSEvent):void
{
var user:User = evt.params.user
debug("user var update: " + user.getName())
var vars:Array = user.getVariables()
for (var key:String in vars)
{
var v:Object = vars[key]
debug("\t" + key + " --> " + v)
}
}
Can you try it and see if it shows the correct values?