onUserEnterRoom question - avatarChat

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

Moderators: Lapo, Bax

Post Reply
Soleil
Posts: 19
Joined: 06 Mar 2010, 06:24

onUserEnterRoom question - avatarChat

Post by Soleil »

Please see my comments in the code below.

Code: Select all

function onUserEnterRoom( evt:SFSEvent ):void
{
	var user:User = evt.params[ "user" ]
	var userId:Number = user.getId()
	var userName:String = user.getName()
	var uVars:Object = user.getVariables()
	var mc:Avatar = Avatar( avatarMC.getChildByName( "avatar_" + userId )) //if the user is just entering the room, how can an avatar with his userId already exist?
	mc = new Avatar //doesn't this line render the previous line useless?
	mc.id = "avatar_" + userId
	mc.name = "avatar_" + userId
	avatarMC.addChild( mc )
//the following two lines trace out as "undefined" for me. I believe this is because the onUserEnterRoom event is received before the user sets up their own variables (which is done in "SetupMyAvatar", which is called from onJoinRoom).
	mc.x = uVars.px
	mc.y = uVars.py
	mc.disc.gotoAndStop( uVars.col )
	mc.uname.text = user.getName()
}
It seems strange to set up the user avatar when they join the room, because the other users in the room are notified that this new user entered the room before the new user can even set it's own properties. Please set me straight on this.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

mc = new Avatar //doesn't this line render the previous line useless?
Yes it does, you are correct.
I think it was inadvertently left there and should be removed.

Thanks for noticing, we'll update in the next release.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply