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()
}