user count from getRoomListFromGroup

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

aliko
Posts: 117
Joined: 09 Mar 2013, 16:26

user count from getRoomListFromGroup

Postby aliko » 04 Jan 2016, 13:48

Hello,

I get the user count from a grupid with below code.
Is there a way to get this count without a loop?

Code: Select all

cnt=0;
var roomList:Array = sfs.roomManager.getRoomListFromGroup(games_grup);
for each(var room:Room in roomList) {
    cnt=cnt+room.userCount;
}
trace("Total user count : "+cnt);
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: user count from getRoomListFromGroup

Postby Lapo » 04 Jan 2016, 15:07

Hi,
what you're doing is correct, in other words aggregating the count of all Rooms in the Group.

There isn't a method in the API to count users in a Group so you could turn this code into a method and invoke it from any place in your code where you need it.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 18 guests