下一个更精彩:处理flash和javascript之间的交互
尝试使用了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 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 = "";
}
} 后者效果图
图片如下:


| · 你会让人一见钟情吗 |
| · 搞笑CS版少女初夜 |
| · 超级女生李宇春终结版 |
| · 智力大挑战连连看 |
| · 美眉换装小游戏合集 |
| · 无与伦比周杰伦火热MTV |
| · 其卡通小奖赛发挥你创意 |
| · 齐达内铁头VS马特拉奇 |
| · ShowGood经典爆笑三国 |
| · 小破孩动画专区 |
| 关于腾讯 | About Tencent | 服务条款 | 广告服务 | 腾讯招聘 | 腾讯公益 | 客服中心 | 网站导航 | |
| Copyright © 1998 - 2008 Tencent Inc. All Rights Reserved | ![]() |
| 腾讯公司 版权所有 | |