Page 1 of 1

problem setting user variables in Flex and CS3

Posted: 29 May 2007, 15:51
by Tom
Hi,

I'm a little new to this -- but I can connect to the server, join rooms, create rooms, and also create room variables... cool. but what i can't seem to do is set user variables. it just brings up errors for me.

in particular:

Code: Select all

TypeError: Error #1009: Cannot access a property or method of a null object reference.  ...
i'm just trying to do something very basic and followed the code in the api documentation.

Code: Select all

var uVars:Object = new Object()
uVars.myAvatar = "Homer"
uVars.posx = 100
uVars.posy = 200

smartFox.setUserVariables(uVars)
that's immediately after my code when i join a room. its simple, it's within the same method... is that too simple? is it trying to set something too soon or what? should i have some sort of listener and wait to set user variables or something?

just puzzled on why setting these user variables is not as straight forward as creating a room and setting room variables.

thanks.

Posted: 29 May 2007, 18:33
by Tom
aha, that was it... i jumped the gun. i moved the setting of user variables down until after it was sure that you were logged in and in a room... (looking at the template provided under the as3/flex examples, i set my user variables after the trace where it says "successfully joined room")

maybe this is common sense to some people but would be helpful to see a process or flow of events...i'm sure i can figure it all out by tracing now, but at what point can you set different variables or get lists of buddies, rooms, etc.? are there any other things to take note about for timing/process/hierarchy?

Posted: 30 May 2007, 08:51
by Lapo
maybe this is common sense to some people but would be helpful to see a process or flow of events...i'm sure i can figure it all out by tracing now, but at what point can you set different variables or get lists of buddies, rooms, etc.? are there any other things to take note about for timing/process/hierarchy?
This is actually stated all over in the documentation, for example in the first tutorials and in particular in this article --> http://www.smartfoxserver.com/docs/docP ... /index.htm

Also I'd recommend reading this --> http://www.smartfoxserver.com/docs/docP ... ecture.htm

Posted: 30 May 2007, 14:45
by Tom
oh. i see. i was kinda ignoring most things that weren't directed at AS3.
even though i see it's related of course.