现在位置:首页->学习专题->Flash/Flv
FMS解决在线用户数读取
作者: 日期: 2007-10-30 12:02:08 访问次数:出处:
 显示选项:自动滚屏[左键停止]
网上有许多教程都这样写:
最简单的计算在线人数的方法
通过 application.clients.length 就可以了
客户端需要的话可以call服务器端定义的函数,最方便的还是使用共享对象来存取了,下面给出完整的实现方法。

在服务器端的main.asc文件中写入:
application.onAppStart = function() {
this.users_so = SharedObject.get('users_so');
};

application.onConnect = function(newClient, name)
{
// Accept the client's connection
application.acceptConnection(newClient);
i = application.clients.length;
this.users_so.setProperty('users', i);
}
application.onDisconnect = function(client)
{
i = application.clients.length;
this.users_so.setProperty('users', i);
}

在客户端fla文件中添加:
users_so = SharedObject.getRemote('users_so', client_nc.uri, false);
// 更新在线用户数
users_so.onSync = function(list) {
txtNumberUsers.text = users_so.data.users;
//==============================
//==============================

但我却取不到?!查遍文档,发现
SharedObject.get()方法,还需要在服务端SharedObject.get()命令中
为persistence参数传递一个值true来创建仅永久于服务器的remote共享对象...
也就是说,在上面的教程中,应该这样
application.onAppStart = function() {
this.users_so = SharedObject.get('users_so',true);
};
才行。
我不知道写教程者这样是否正常,反正我这不行,必须加了true才成。
⊕相关文章
  • ·用SSAS将多个FLV和MP3文件合成一个FLV文件
  • ·使用FMS(FCS)来合并多个flv视频文件的实现
  • ·flash remoting实践
  • ·基于Flash Media Server的Flash多人涂鸦白板
  • ·Flash Media Server 2的功能
  • ·如何转换视频为flv文件过程记录