|
探索Flash Media Server(二)
尝试使用了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 = ""; } } 后者效果图 图片如下:
责任编辑:uufeng 时间:2006年8月25日
|