Page 1 of 1

Another client problem

Posted: 13 Apr 2007, 20:07
by Dr_Malito
I have this:

Code: Select all

function onUserVariablesUpdate(userObj:User, changedVars:Array)
{
	trace("onUserVariablesUpdate:" + userObj + ", changed vars: " + changedVars)
		
	var variables:Object = userObj.getVariables()
	var px:Number = variables["ypos"]
	var py:Number = variables["ypos"]
	
	trace("User: " + userObj.getName() + " is now located at " + px + ", " + py)
}
And get this.
[Received]: <msg t="sys"><body action="uVarsUpdate" r="7"><vars><var n="xpos" t="n">3879</var><var n="ypos" t="n">3296</var></vars><user id="5" /></body></msg>
onUserVariablesUpdate:undefined, changed vars: xpos,ypos
User: undefined is now located at undefined, undefined
seems that the smartfox client is receiving the vars, but they are not been legible or associable to the object.

any idea?

Posted: 16 Apr 2007, 07:54
by Lapo
Sorry which API version are you using? AS 2 or AS 3?

In order to trace the API version:

Code: Select all

trace(sfs.getVersion())
where sfs is your SmartFoxClient instance

Posted: 16 Apr 2007, 14:41
by Dr_Malito
it's 1.3.7

I'm using AS 2.0

The SmartFox Client is in a external class "SFClient"

Code: Select all

import it.gotoandplay.smartfoxserver.*

class SFClient
{

private var smartfox:SmartFoxClient;
private var ip:String;
private var port:Number;
private var zone:String;

 function SFClient()
 {
  this.ip	 = "127.0.0.1";
  this.port = 9339;
  this.zone = "mw";
  this.extensionName = "mwlogin";
		
  this.smartfox = new SmartFoxClient();
  this.smartfox.debug = true;
  
  this.smartfox.onConnection = this.handleConnection;
  this.smartfox.connect(ip, port);

.....more code

Posted: 16 Apr 2007, 14:46
by Lapo
You are probably trying to set the variables before you have populated the roomList. Without that data the client API won't be able to identify the user who set the variables.

Check your code and additionally see our examples for further reference (The avatar chat, for example)

Posted: 16 Apr 2007, 16:19
by Dr_Malito
Thanks lapo!

problem resolved :D