Page 1 of 1

getBuddyRoom returning undefined?

Posted: 20 Sep 2011, 00:10
by KevinLD
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

Posted: 20 Sep 2011, 22:06
by BigFIsh
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])
}

Posted: 20 Sep 2011, 23:53
by KevinLD
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?