直接复制以下代码,场景大小设置成80*22,只访问网络,就可以输入对方QQ号,回车之后,即可直接聊天了。
//===========屏闭菜单============
fscommand("showmenu", false);
//===========创建文本格式======
var txt_fmt:TextFormat = new TextFormat();
txt_fmt.size = 16;
txt_fmt.bold = true;
txt_fmt.color = Math.random()*0xffffff;
//===========创建输入QQ号的文本======
var QQ_txt:TextField = this.createTextField("QQ_txt", 2, 0, 0, 80, 22);
QQ_txt.border = true;
QQ_txt.type = "input";
QQ_txt.restrict = "0-9";
QQ_txt.maxChars = 9;
//===========创建输入QQ号的文本======
QQ_txt.setNewTextFormat(txt_fmt);
//===========回车动作设置======
this.onKeyDown = function() {
//======如果回车时QQ号大于5位就打开面板======
if (Key.getCode() == 13 && QQ_txt.text.length>=5) {
getURL("tencent://message/?uin="+QQ_txt.text);
}
};
//======QQ输入文本框得到焦点时,注册键盘帧听======
QQ_txt.onSetFocus = function() {
Key.addListener(this._parent);
};
//======QQ输入文本框失去焦点时,卸载键盘帧听======
QQ_txt.onKillFocus = function() {
Key.removeListener(this._parent);
};