0

*您好!我只需要在列表组件中显示的 dataProvider 上填充 100 个项目。即使物品超过500甚至1000,我也只想要100个物品,首先是所有打开相机的物品,然后填充其余的总共完成100个在DataProvider上。使用 ActionScript 3.0 (Flash CC):

更新:基本上,我需要的是:我在 Flash 中有一个视频聊天应用程序,所以当有数百个用户时,由于列表组件填充了数百个项目(用户),应用程序变得很慢,所以我希望至少有 100 个列表中的用户优先考虑用户流式传输的实时视频。是否有意义?:) 谢谢- 亚历克斯刚刚编辑
*

代码:

function syncEventHandler(event:SyncEvent){
        list1.removeAll();

             for (var i in users_so.data){

                 if (users_so.data[i] != null)
                      {
                          var clientObj = users_so.data[i];
                //if user is streaming add it first then complete 100 with the rest.
                          list1.addItem({label:clientObj.UserName});
                      }


            }
    }

谢谢你花时间做这个!

4

1 回答 1

0

我不确定你的意图是什么,但你可以通过实现一个全局计数器来限制数据提供者中的项目数量,如下所示:

function syncEventHandler(event:SyncEvent)
{
    list1.removeAll();
    counter = 0;
    for (var i in users_so.data)
    {

        if (users_so.data[i] != null)
        {
             if(counter < 100)
             {
                 var clientObj = users_so.data[i];
                 //if user is streaming add it first then complete 100 with the rest.
                 list1.addItem({label:clientObj.UserName});
                 counter ++;
             }
             else
             {
                 break;
             }
        }

    }
}
于 2014-02-09T18:44:34.213 回答