problem setting user variables in Flex and CS3

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
Tom
Posts: 20
Joined: 27 Apr 2007, 21:04

problem setting user variables in Flex and CS3

Post 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.
Tom
Posts: 20
Joined: 27 Apr 2007, 21:04

Post 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?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
Tom
Posts: 20
Joined: 27 Apr 2007, 21:04

Post 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.
Post Reply