Expand my Community achievements bar.

Flash cs4 userCollection to dataprovider/list

Avatar

Level 2

Hi,

I'm stuck trying to get the userCollection into a list.

The flex docs say...

<mx:List dataProvider="{cSession.userManager.userCollection}"

but I'm not sure how to do it in flash.

Suggestions appreciated, thanks.

Graeme

3 Replies

Avatar

Level 2

  Looks like this does the trick...

   var userArray:Array  = session.userManager.userCollection.source;
   var dp:DataProvider  = new DataProvider();
   for (var i in userArray)
   {
    dp.addItem({label:userArray[i].displayName});
   }
   uList.dataProvider = dp;

Not sure if it is the right approach, but I'll go with that unless anyone corrects me.

Thanks,

Graeme

Avatar

Employee

This works to give you the current status of the user list. If a user enter / exit the room, however, your DataProvider will not get updated.

You should attach an event listener to session.userManager.userCollection (or probably directly to userManager), and on the event handler add/remove items from the data provider.

Avatar

Level 2

OK, that makes sense. Thanks for your help.