# \[F8\] userList and SspectatorList problem

**URL:** <https://forum.kirupa.com/t/f8-userlist-and-sspectatorlist-problem/295301>\
**Category:** flash\
**Created:** [August 27, 2009, 8:41pm UTC](https://forum.kirupa.com/t/f8-userlist-and-sspectatorlist-problem/295301 "2009-08-27T20:41:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![capdetrons](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capdetrons](https://forum.kirupa.com/u/capdetrons)\
**Post date:** [August 27, 2009, 8:41pm UTC](https://forum.kirupa.com/t/f8-userlist-and-sspectatorlist-problem/295301/1 "2009-08-27T20:41:50Z")

</div>

Hi,  
Is anyone using electroserver or might have an idea of why this is happening in a game where you can send private messages by clicking on the userList but not when you click on the spectatorList?  
I don’t know much actionscript, but I thought it was just a matter of setting a listener…  
both lists are on the same timeline and they are both populated, but the spectatorListBox users don’t pop up the message clip.  
I have both a user and a spectator list in my game where I can send privaate messages to the user listBox users, but not to the spectator listbox users. Can anyone help me with this? I have looked thorugh the code over and over and have no idea of what else to try.  
I thought this code would be enough to get it to work?  
spectatorListBox.dataProvider = spectatorList;  
var spectatorClickListenerObject:Object = new Object();  
spectatorClickListenerObject.change = function(eventObject) {  
var user:Object = eventObject.target.value;  
if (es.getUser().attributes.Moderator) {  
showPopUp(“moderator”, user);  
} else {  
showPopUp(“private”, user);  
}  
};  
spectatorListBox.addEventListener(“change”, spectatorClickListenerObject);  
this is the userList clickListener:  
var userClickListenerObject:Object = new Object();  
userClickListenerObject.change = function(eventObject) {  
var user:Object = eventObject.target.value;  
if (es.getUser().attributes.Moderator) {  
showPopUp(“moderator”, user);  
} else {  
showPopUp(“private”, user);  
}  
};  
userListBox.addEventListener(“change”, userClickListenerObject);  
and this is the show users function where the two lists are created:  
function showUsers(userList, type, name) {  
if (type == “userleft” && name == opponent) {  
game\_clip.opponent\_left();  
}  
//get the user list  
var userlist = es.getUserList();  
//We will be building a player list and a spectator list.  
playerList = new Array();  
spectatorList = new Array();  
//Max players allowed in this game  
maxPlayers = es.getRoom().Description.attributes.numPlayers;  
allowSpectators = es.getRoom().Description.attributes.allowSpectators;  
//Your assigned number, if you have one  
myNum = es.getUser().AssignedNumber.value;  
var highestNum:Number = 0;  
for (var i = 0; i\<userlist.length; ++i) {  
var user:Object = userlist\*;  
//The user’s assigned number  
var num:Number = user.AssignedNumber.value;  
if (num\>=0 && num != undefined && num != null && num\<maxPlayers) {  
//Add them to the player list  
if (num\>highestNum) {  
highestNum = num;  
}  
user.gamePlayer = true;  
playerList.push(user);  
} else {  
//Add them to the spectator list  
user.gamePlayer = false;  
spectatorList.push(user);  
}  
}  
//Populate the on-screen list boxes  
showBothListBoxes();  
if (playerList.length == maxPlayers && myNum == 0) {  
//If everyone is here and you are player 0 (i.e., the game master), then tell everyone to start the process  
sendStartMove(playerList[1].Name.value);  
} else if (playerList.length == maxPlayers && myNum == 1) {  
sendStartMove();  
} else if (playerList.length == maxPlayers) {  
spectatorStart();  
}  
if (!es.getUser().gamePlayer && es.getUser().AssignedNumber.value\>=maxPlayers) {  
//This happens when you click to join as a player but someone else just barely beats you to it to fill out he game  
//This user should be informed and given the option to watch or leave  
if (!allowSpectators) {  
//They don’t allow spectators. You tried to join as a player but the game was full  
goBack();  
}  
}  
if (es.getRoom().Description.attributes.playersArrived != highestNum+1 && es.getUser().isGameMaster) {  
//+1 because the numbering starts from 0  
changeDetail(highestNum+1);  
}  
game\_clip.setGamePlayerList(playerList);  
game\_clip.setSpectatorList(spectatorList);  
}  
function showBothListBoxes() {  
spectatorListBox.dataProvider = spectatorList;  
}
