📄 face.as
字号:
package cn.humanmonth.chat{
import flash.events.MouseEvent;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import mx.collections.ArrayCollection;
import mx.containers.Panel;
import mx.controls.Button;
import mx.controls.List;
import mx.controls.TextArea;
import mx.controls.TextInput;
import mx.core.IUITextField;
import mx.core.UIComponent;
import mx.core.mx_internal;
import mx.events.FlexEvent;
/**
*
* @author Piterlin
* 聊天室的UI
*/
public class Face {
private var msgArea:TextArea;
private var myIn:TextInput;
private var users:ArrayCollection=new ArrayCollection();
private var userList:List;
private var borderPane:Panel;
private var inputPanel:Panel;
private var sendButton:Button;
private var changeNameButton:Button=new Button();
public function Face(myIn:TextInput,msgArea:TextArea,userList:List,borderPane:Panel,sendButton:Button,inputPanel:Panel) {
this.borderPane=borderPane;
var tf:IUITextField=borderPane.mx_internal::getStatusTextField();
tf.htmlText="<a href='http://humanmonth.cn/GeleralLayoutServlet.do?fileName=him'>人月软件</a>";
tf.selectable=true;
this.myIn=myIn;
this.msgArea=msgArea;
this.msgArea.htmlText="(系统消息):登录中```<br>";
msgArea.addEventListener(FlexEvent.UPDATE_COMPLETE,textAreaUpdateEvent);
this.userList=userList;
this.userList.contextMenu=this.getPrivateChatContextMenu();
this.userList.dataProvider=users;
this.sendButton=sendButton;
this.inputPanel=inputPanel;
var titleBar:UIComponent=inputPanel.mx_internal::getTitleBar();
changeNameButton.width=20;
changeNameButton.height=20;
changeNameButton.move(titleBar.width-30,titleBar.height-23);
changeNameButton.label="名";
changeNameButton.toolTip="点击此按钮可以更改你的昵称。";
titleBar.addChild(changeNameButton);
}
private function getPrivateChatContextMenu():ContextMenu{
var contextMenu:ContextMenu=new ContextMenu();
var contextMenuIten:ContextMenuItem=new ContextMenuItem("私聊");
contextMenu.hideBuiltInItems();
contextMenu.customItems.push(contextMenuIten);
return contextMenu;
}
public function addChangeNameListener(fun:Function):void{
this.changeNameButton.addEventListener(MouseEvent.CLICK,fun);
}
public function textAreaUpdateEvent(event:FlexEvent):void{
this.getMsgArea().verticalScrollPosition=this.getMsgArea().maxVerticalScrollPosition;
}
public function getMsgArea():TextArea {
return this.msgArea;
}
public function getMyIn():TextInput {
return this.myIn;
}
public function getUsers():ArrayCollection {
return this.users;
}
public function getSendButton():Button{
return this.sendButton;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -