快速业务通道

Flash MX 编程深层次应用-网络连线游戏(4)

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-10
体加粗、加超级链接,如图7-13所示。 图7-13 其相关程序如下: on (release) { ??? //斜体字 ??? text = text+" "; ??? Selection.setFocus("text"); ??? Selection.setSelection(text.length-1,text.length-1); } on (release) { ??? //字体加粗 ??? text = text+" "; ??? Selection.setFocus("text"); ??? Selection.setSelection(text.length-1,text.length-1); } on (release) { ??? //字体加超级链接 ??? text = text+"http://"; ??? Selection.setFocus("text"); ??? Selection.setSelection(text.length-1,text.length-1); } 信息发送按钮 这些都比较容易,让我们把精力放在发送按钮上吧,程序如下: on (release, keyPress "") { ??? //文本输入框为空就什么都不做 ??? if (text == null || trim(text) == "") { ???????????? return; ??? } ??? text = trim(text); ??? //如果是在下棋状态,则所有聊天的内容只发给下棋的对手,采用私聊方式发送 ??? if (_root.now_play_table != 0) { ???????????? text = "/p "+_root.rival+" "+text; ??? } else { ???????????? if (text.charAt(0) != "/" && trim(target) != null && trim(target) != "") { ????????????????????? text = "/target "+target+" "+text; ???????????? } ??? } ??? //对输入串进行特别字符变换 ??? text = _root.encode(text); ??? var chatXML; ??? var m_Message; ??? chatXML = new XML(); ??? if (text.charAt(0) == "/") { ???????????? // cmds ???????????? if (text.charAt(1) == "/") { ????????????????????? //双斜杠命令,可以完成一些系统管理方面的功能 ????????????????????? if (trim(target) != null && trim(target) != "") { ??????????????????????????????? text += " "+target; ????????????????????? } ????????????????????? m_Message = chatXML.createElement("CMD"); ????????????????????? m_Message.attributes.VALUE = "ACT"; ????????????????????? m_Message.attributes.PARAM = text.substring(2); ????????????????????? chatXML.appendChild(m_Message); ???????????? } else { ????????????????????? // 单斜杠命令,有一些系统的简单功能 ????????????????????? m_Message = chatXML.createElement("CMD"); ????????????????????? var cmdEnd = text.indexOf(" "); ????????????????????? if (cmdEnd != -1) { ??????????????????????????????? m_Message.attributes.VALUE = text.substring(1, cmdEnd); ??????????????????????????????? m_Message.attributes.PARAM = text.substring(cmdEnd+1); ????????????????????? } else { ??????????????????????????????? m_Message.attributes.VALUE = text.substring(1); ????????????????????? } ????????????????????? chatXML.appendChild(m_Message); ???????????? } ??? } else { ???????????? // 正常的聊天语句 ???????????? m_Message = chatXML.createElement("TXT"); ???????????? m_Message.attributes.VALUE = text; ???????????? chatXML.appendChild(m_Message); ??? } ??? trace(chatXML.toString()); ??? // 发送聊天内容 ??? _root.chatSocket.send(chatXML); ??? text = ""; ??? Selection.setFocus("text"); ??? function trim(strin) { ???????????? var i, j; ??? ???????? for (i=0; i=i; j--) { ????????????????????? if (strin.charAt(j) != '' '') { ??????????????????????????????? break; ????????????????????? } ???????????? } ???????????? return strin.substring(i, j+1); ??? } } 上面的程序从某种意义上讲是一个简单的命令

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号