user count from getRoomListFromGroup

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

Moderators: Lapo, Bax

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

user count from getRoomListFromGroup

Post by aliko »

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: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: user count from getRoomListFromGroup

Post by Lapo »

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
Post Reply