探索Flash Media Server(二) |
| 作者:佚名 来源:不详 更新:2007-1-13 20:36:25 错误报告 我要投稿 |
尝试使用了SharedObject类
使用Local SharedObject
import mx.utils.Delegate; var lso:SharedObject = SharedObject.getLocal("test", "/"); output_txt.text = lso.data.msg; input_txt.addEventListener("keyDown", Delegate.create(this, inputFunc)); function inputFunc(obj) { if (Key.isDown(Key.ENTER)) { lso.data.msg = obj.target.text; obj.target.text = ""; if (lso.flush()) { trace("write success"); } } }
使用Remote SharedLocal //连接 var nc:NetConnection = new NetConnection(); var rso; nc.onStatus = checkConnect; nc.connect("rtmp://localhost/test1"); function checkConnect() { if (this.isConnected) { rso = SharedObject.getRemote("test", nc.uri); rso.connect(nc); rso.onSync = checkRso; } } //显示信息 function checkRso(obj) { var txt = this.data.msg; if (txt.length>3) { txt.shift(); } if (txt != undefined) { msg_txt.text = ""; for (var i = 0; i<txt.length; i++) { msg_txt.text += txt[i]+newline; } } } //发送信息 import mx.utils.Delegate; input_txt.addEventListener("keyDown", Delegate.create(this, inputFunc)); function inputFunc(obj) { if (rso.data.msg == undefined) { rso.data.msg = []; } if (Key.isDown(Key.ENTER)) { rso.data.msg.push(obj.target.text); obj.target.text = ""; } } 后者效果图 图片如下:

|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |