有时候,客户端历史记录不断的增加,会导致Flash运行和反应的迟钝,可以通过限制历史记录数的方法改善。
在客户端的chat组件代码中找到receiveMessage方法,使用下面的代码替换
2 : //this.history_txt.htmlText += mesg; 这行是原先的实现代码
3 : this.history.push(mesg);
4 : if (this.history.length>30) this.history.shift();
5 : this.history_txt.htmlText = this.history.join("");
6 : this.history_txt.scroll = this.history_txt.maxscroll;
7 : }
其中限制记录数可以自己调整,这里设为30。
在FCChatClass.prototype.init方法中定义history数组来保存本地聊天记录信息
还有一个地方要注意,在清空历史时候,也要把本地聊天记录数组清空: