getBuddyRoom returning undefined?

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

Moderators: Lapo, Bax

KevinLD
Posts: 2
Joined: 19 Sep 2011, 23:52

getBuddyRoom returning undefined?

Postby KevinLD » 20 Sep 2011, 00:10

Hello,

I'm trying to add getBuddyRoom onto my Buddylist item's, but whenever an online buddy shows up, it says that the room they are in is undefined. Why would it do this?

I have attached an image of the result, as well as my code:

Code: Select all

   public function LoadFromBuddy(_buddy: Object) {
         m_buddy = _buddy;
         
         var t1: String = "";
         
         _buddy.isOnline ? t1 = "is Online!" : t1 = "Offline"
         var _title: String = _buddy.name + " " + t1;
         
         if (_buddy.isOnline == true){
            dtf_room.text = "Inside: " + _buddy.getBuddyRoom
         }
         else{
            removeChild(dtf_room)
         }
         
         dtf_title.text = _title;
         _buddy.isOnline ? btn_invite.enabled = true :  btn_invite.enabled = false;
         _buddy.isOnline ? btn_invite.visible = true :  btn_invite.visible = false;
         _buddy.isOnline ? btn_teleport.enabled = true :  btn_teleport.enabled = false;
         _buddy.isOnline ? btn_teleport.visible = true :  btn_teleport.visible = false;
}


Image
Image
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 20 Sep 2011, 22:06

That's not how it's done. According to the actionscript documentation, it's:

smartFox.addEventListener(SFSEvent.onBuddyRoom, onBuddyRoomHandler)

var buddy:Object = smartFox.getBuddyByName("jack")
smartFox.getBuddyRoom(buddy)

function onBuddyRoomHandler(evt:SFSEvent):void
{
// Reach the buddy in his room
smartFox.join(evt.params.idList[0])
}
Smartfox's forum is my daily newspaper.
KevinLD
Posts: 2
Joined: 19 Sep 2011, 23:52

Postby KevinLD » 20 Sep 2011, 23:53

Surely my code should work, though? I have already called through Smartfox the individual buddy (as I'm calling his name and whether he is on/offline within this function) so it knows his name and ID, I'm just calling the function alongside his name.

Surely, if this doesn't work, _buddy.isOnline and _buddy.name shouldn't work?

Or, am I missing something obvious here?

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 47 guests