Anunnakispirit
05-28-2006, 06:31 PM
Flex 2 Beta 3 : ActionScript 3!
I am writing a chat client with audio/video support, and I'm having a bit of a problem adding users to the list component. After alot of confusion I managed to actually get them to add to the list using an array. But when a user joins the room, it shows all the nicknames again. For Example. I join as Guest1, Guest 1 gets added to the list, then I join under another name e.g Guest2; on the Guest1 client it displays Guest1, Guest1, Guest2...Which says to me, it has added the array when they join, but then it fetches the details again and adds them to the list ontop of the other. There must be a way to refresh the list, like remove the values and readd the array items. I'm not sure how, and I've only been doing actionscript for two weeks. (Also I apologise if there was another thread on this, I did search, and looked through about 5 pages of returned search results but none were particularly useful to what I'm doing) Please help me if you can, thanks!
//This is at the top of the code where myarray is defined as an array
public var myarray:Array =[""];
[Bindable]
public var collection:ArrayCollection = new ArrayCollection();
//this is an event listener for users_so:SharedObject;
private function UserGetSync(event:SyncEvent):void
{
//Create a new array
var collection:ArrayCollection=new ArrayCollection(myarray);
for(var i:* in users_so.data) {
//users_so.data[i] is the nickname retrieved from FMS
if(users_so.data[i]!=null) {
//add the retrieved nickname from user_so.data[i] to the array
//There should be something here to refresh the NickList before adding users so it don't list on top of the last listing(which is where my problem lies)
collection.addItem(users_so.data[i]);
NickList.dataProvider=collection;
}
}
I am writing a chat client with audio/video support, and I'm having a bit of a problem adding users to the list component. After alot of confusion I managed to actually get them to add to the list using an array. But when a user joins the room, it shows all the nicknames again. For Example. I join as Guest1, Guest 1 gets added to the list, then I join under another name e.g Guest2; on the Guest1 client it displays Guest1, Guest1, Guest2...Which says to me, it has added the array when they join, but then it fetches the details again and adds them to the list ontop of the other. There must be a way to refresh the list, like remove the values and readd the array items. I'm not sure how, and I've only been doing actionscript for two weeks. (Also I apologise if there was another thread on this, I did search, and looked through about 5 pages of returned search results but none were particularly useful to what I'm doing) Please help me if you can, thanks!
//This is at the top of the code where myarray is defined as an array
public var myarray:Array =[""];
[Bindable]
public var collection:ArrayCollection = new ArrayCollection();
//this is an event listener for users_so:SharedObject;
private function UserGetSync(event:SyncEvent):void
{
//Create a new array
var collection:ArrayCollection=new ArrayCollection(myarray);
for(var i:* in users_so.data) {
//users_so.data[i] is the nickname retrieved from FMS
if(users_so.data[i]!=null) {
//add the retrieved nickname from user_so.data[i] to the array
//There should be something here to refresh the NickList before adding users so it don't list on top of the last listing(which is where my problem lies)
collection.addItem(users_so.data[i]);
NickList.dataProvider=collection;
}
}