📄 chatui.as
字号:
function ChatUI(inMC) { this.mc = inMC; this.mc.chatUI = this; _global.FlashChatNS.chatUI = this; _global.FlashChatNS.BigSkin_Loaded = false; this.mc.loader = new MovieClipLoader(); this.mc.loader.addListener(this.mc); this.selfUserId = null; this.selfUserRole = null; this.selfUserGender = null; this.selfRoomId = null; this.selfInitialized = false; this.firstInit = false; this.layoutMinWidth = this.DEFAULT_LAYOUT_MIN_WIDTH; this.layoutLeftPaneMinWidth = 0; this.layoutMinHeight = this.DEFAULT_LAYOUT_MIN_HEIGHT; this.floodIntervalTime = this.getTimeMilis(); this.gagIntervalTime = 0; //settings. this.settings = null; //languages. this.languages = null; this.selectedLanguage = null; //keeps reference to 'initial skin' object. it is initialized at flash startup by //'setInitialSkin(...)' call from chat manager. initial skin is used to draw login box only. this.initialSkin = null; this.initialBigSkin = null; this.initialText = null; //keeps an 'id' of initial language. it is used to set up language chooser in login box. this.initialLanguageId = null; this.rooms = new Object(); //this.users = new Object(); //default position of panels this.userListPosition = this.USERLIST_POSITION_RIGHT; this.optionPanelPosition = this.OPTIONPANEL_POSITION_BOTTOM; this.userList_XScale = null; this.userList_XScalePrev = null; this.optionPanel_YScale = null; this.optionPanel_YScalePrev = null; //create dialog holder this.mc.createEmptyMovieClip('dialogHolder', 15000); this.mc.dialogHolder.baseDepth = 4; //0,1,2,3 layers is reserved for pane windows when docked this.mc.dialogHolder.currentDepth = 4; this.mc.dialogHolder.depthHash = new Object(); this.privateBoxManager = new CPrivateBoxManager(this.mc.dialogHolder, Stage.width, Stage.height); this.privateBoxManager.setPrivateBoxHandler('onPrivateBoxSend', this); this.dialogManager = new CDialogManager(this.mc.dialogHolder, Stage.width, Stage.height); this.dialogManager.setHandler('onNewDialogShow', this); //userList init this.userListPane = this.dialogManager.createPane('userList'); this.mc.userList = this.userListPane.setContent('CustomListView'); this.userListPane.setDockState(false); //inputTextArea init this.inputTextAreaPane = this.dialogManager.createPane('inputTextArea'); var inputTextArea = this.inputTextAreaPane.setContent('InputTextArea', this, 'postAtachment'); this.mc.sendBtn = inputTextArea.sendBtn; this.mc.optionPanel = inputTextArea.optionPanel; this.mc.msgTxt = inputTextArea.msgTxt; this.mc.msgTxtBackground = inputTextArea.msgTxtBackground; this.mc.optionPanelBG = inputTextArea.optionPanelBG; this.inputTextAreaPane.setDockState(false); this.listener = null; this.sendButtonEnabled = false; this.waitingForResponse = false; this.mc.logOffBtn.setClickHandler('processLogOffButton', this); //this.mc.logOffBtn.setStyleProperty('textAlign', 'right'); this.mc.createEmptyMovieClip('userMenuContainer', 35000); this.smileDropDownCloserIntervalId = null; this.setInputFocusIntervalId = null; this.inactivityIntervalId = null; this.bigSkinIntervalId = null; this.mc.backgroundImageHolder.attachMovie('Image', 'image', 0); this.mc.backgroundImageHolder.createEmptyMovieClip('mask', 1); this.mc.backgroundImageHolder.mask.drawRect2(0, 0, 1, 1, 0, 0, 100, 0xffffff, 100); this.mc.backgroundImageHolder.setMask(this.mc.backgroundImageHolder.mask); this.mc.backgroundImageHolder.image.setHandler('imageLoaded', this.mc); this.mc.imageLoaded = function(inImg) { _global.FlashChatNS.chatUI.resizeImageBG(this.backgroundImageHolder.image); } //chat window attach this.mc.smileTextHolder.depth = 0; this.mc.chatLog = this.mc.smileTextHolder.attachMovie('SmileText', 'chatLog', this.mc.smileTextHolder.depth++); this.soundObj = new SoundEngine( _level0.ini["sound_options"], _level0.ini["sound"], this ); this.setControlsVisible(false); this.setControlsEnabled(false); //dbg( _level0.ini["sound"] ); //if focus target is null, focus will return to main input box. otherwise, focus will //go to the textfield, specified in 'focusTarget'. used to transfer focus to private popup boxes. this.focusTarget = null; //***************************************************************************************** //pre-cache slow dialogs. /*var tmpDialog = this.dialogManager.createDialog('PropertiesBox'); this.dialogManager.releaseDialog(tmpDialog); var tmpDialog = this.dialogManager.createDialog('SoundPropertiesBox'); this.dialogManager.releaseDialog(tmpDialog); //this call clears dialog manager 'bounds cache'. if clear() implementation will be changed, //i.e. it will remove all pre-cached dialogs from memory, the above code will lose sense. this.dialogManager.clear();*/ //***************************************************************************************** this.createModule();}//CONSTANTS.ChatUI.prototype.SPACER = 5;ChatUI.prototype.OP_SPACER = 3;ChatUI.prototype.DEFAULT_LAYOUT_MIN_WIDTH = 410;ChatUI.prototype.DEFAULT_LAYOUT_MIN_HEIGHT = 280;ChatUI.prototype.USER_MENU_PRIVATE_MESSAGE = 'Private message';ChatUI.prototype.USER_MENU_INVITE = 'Invite';ChatUI.prototype.USER_MENU_IGNORE = 'Ignore';ChatUI.prototype.USER_MENU_UNIGNORE = 'Unignore';ChatUI.prototype.USER_MENU_BAN = 'Ban';ChatUI.prototype.USER_MENU_UNBAN = 'Unban';ChatUI.prototype.USER_MENU_PROFILE = 'Profile';ChatUI.prototype.USER_MENU_FILE_SHARE = 'Share File';//--- share menu labelChatUI.prototype.USER_STATE_HERE = 1;ChatUI.prototype.USER_STATE_BUSY = 2;ChatUI.prototype.USER_STATE_AWAY = 3;ChatUI.prototype.USER_STATE_LIST = [[ChatUI.prototype.USER_STATE_HERE, 'Here'], [ChatUI.prototype.USER_STATE_BUSY, 'Busy'], [ChatUI.prototype.USER_STATE_AWAY, 'Away']];ChatUI.prototype.USERLIST_POSITION_RIGHT = 1;ChatUI.prototype.USERLIST_POSITION_LEFT = 2;ChatUI.prototype.USERLIST_POSITION_DOCKABLE = 3;ChatUI.prototype.OPTIONPANEL_POSITION_BOTTOM = 1;ChatUI.prototype.OPTIONPANEL_POSITION_TOP = 2;ChatUI.prototype.OPTIONPANEL_POSITION_DOCKABLE = 3;ChatUI.prototype.DRAG_FRAME_COLOR = 0x000000;ChatUI.prototype.DRAG_FRAME_THICKNESS = 2;//PUBLIC METHODS.ChatUI.prototype.postAtachment = function(inObj){ this.setControlsVisible(false); this.setControlsEnabled(false); //---userList--------------------------------------------------------------------------------------// this.mc.userList.addListener(this); this.mc.userList.setPressHandler(this, 'processDragFrame'); //---optionPanelBG---------------------------------------------------------------------------------// this.mc.optionPanelBG.onPress = function() { _global.FlashChatNS.chatUI.processDragFrame(this._parent._parent._parent); } //---create-user-list-resizer----------------------------------------------------------------------// this.mc.createEmptyMovieClip('customListView_resizer', 10000); this.mc.customListView_resizer.onPress = this.resizer_onPress; this.mc.customListView_resizer.onRelease = this.mc.customListView_resizer.onReleaseOutside = this.resizer_onRelease; this.mc.customListView_resizer.onRollOver = this.showStretcher; this.mc.customListView_resizer.onRollOut = this.hideStretcher; this.mc.customListView_resizer.owner = this.mc; this.mc.customListView_resizer.symbolName = 'userList'; //---create-input-text-area-resizer----------------------------------------------------------------------// this.mc.createEmptyMovieClip('inputTextArea_resizer', 10010); this.mc.inputTextArea_resizer.onPress = this.resizer_onPress; this.mc.inputTextArea_resizer.onRelease = this.mc.inputTextArea_resizer.onReleaseOutside = this.resizer_onRelease; this.mc.inputTextArea_resizer.onRollOver = this.showStretcher; this.mc.inputTextArea_resizer.onRollOut = this.hideStretcher; this.mc.inputTextArea_resizer.owner = this.mc; this.mc.inputTextArea_resizer.symbolName = 'inputTextArea'; //-------------------------------------------------------------------------------------------------// this.mc.roomChooser.setChangeHandler('onRoomChanged', this); //this fixes a bug in MM component. there where an error in original 'onTextChange' method //that caused component to behave strange when deleteing text with DELETE key and cursor in 0 pos. this.mc.msgTxt.onTextChange = function(){ if(this.maskingFunction!=undefined){ var len = this.text.length; var index = Selection.getCaretIndex()-1; if (index != -1) { var char = this.text.substring(index,index+1); char = this.maskingScope[this.maskingFunction](char, index, this.text); if(char=="") Selection.setSelection(index,index); this.text= this.text.slice(0,index)+char+this.text.slice(index+1,len); } else { //simply call masking function. this.maskingScope[this.maskingFunction](null, 0, this.text); } } this.onChanged(); }; var initialTF = this.mc.msgTxt.getNewTextFormat(); initialTF.size = _level0.ini.text.itemToChange.mainChat.fontSize; this.mc.msgTxt.setTextFormat(initialTF); this.mc.msgTxt.setNewTextFormat(initialTF); //this.mc.msgTxt.setMaskingFunction('inputTextMask', this); this.mc.msgTxt.textfield_txt.onChanged = this.smileTextOnChanged; this.mc.msgTxt.background = false; this.mc.msgTxt.textfield_txt.border = false; this.mc.msgTxt.textfield_txt.onSetFocus = function() { var p = _global.FlashChatNS.chatUI.mc; p.roomChooser.myOnKillFocus(); this._parent.borderColor = this._skin.bodyText; p.chatUI.textController.onTextFieldSetFocus(); }; this.mc.msgTxt.textfield_txt.onKillFocus = function() { var p = _global.FlashChatNS.chatUI.mc; this._parent.borderColor = this._skin.borderColor; p.chatUI.textController.onTextFieldKillFocus(); }; this.mc.addRoomBtn.setClickHandler('processAddRoom', this); this.mc.sendBtn.setClickHandler('processSend', this); //this.mc.optionPanel.statusLabel.autoSize = 'right'; this.mc.optionPanel.bellLabel.autoSize = 'left'; for (var i = 0; i < this.USER_STATE_LIST.length; i ++) { this.mc.optionPanel.userState.addItem(this.USER_STATE_LIST[i][1], this.USER_STATE_LIST[i]); } this.mc.optionPanel.userState.setChangeHandler('onUserStateChanged', this); this.mc.optionPanel.colorChooser.setChangeHandler('onUserColorChanged', this); this.mc.optionPanel.btnSkinProperties.setClickHandler('processTabbedProperties', this); this.mc.optionPanel.btnClear.setClickHandler('processClear', this); this.mc.optionPanel.btnSave.setClickHandler('processSave', this); this.mc.optionPanel.btnHelp.setClickHandler('processHelp', this); this.mc.optionPanel.btnBell.setClickHandler('processBell', this); this.mc.optionPanel.smileDropDown.setItemSymbol('SmileDropDownCustomItem'); this.mc.optionPanel.smileDropDown.setChangeHandler('onSmileDropDownChanged', this); this.mc.optionPanel.smileDropDown.setClickHandler('onSmileDropDownCliked', this); //set text controler var t = this.textController = new EditController(this.mc); t.setTargetTextField( this.mc.msgTxt ); // Bold Button t.bindComponent(this.mc.optionPanel.bold_ib,"bold","Button"); // Italic Button t.bindComponent(this.mc.optionPanel.italic_ib,"italic","Button");};ChatUI.prototype.drawRect = function(x1,y1,x2,y2,l_gauge,l_color,l_alpha,fill_color,fill_alpha,sourceObj){ //trace('x1 ' + x1 + ' y1 ' + y1 + ' x2 ' + x2 + ' y2 ' + y2); //trace('l_gauge ' + l_gauge + ' l_color ' + l_color + ' l_alpha ' + l_alpha + ' fill_color ' + fill_color + ' fill_alpha ' + fill_alpha + ' sourceObj ' + sourceObj); if (arguments.length < 4){ return; } if (arguments.length < 7 && arguments.length > 4) sourceObj.lineStyle(l_gauge, l_color); else sourceObj.lineStyle(l_gauge, l_color, l_alpha); if(fill_color != undefined && fill_alpha != undefined && fill_alpha >= 0) sourceObj.beginFill(fill_color,fill_alpha); sourceObj.moveTo(x1,y1); sourceObj.lineTo(x2,y1); sourceObj.lineTo(x2,y2); sourceObj.lineTo(x1,y2); sourceObj.lineTo(x1,y1); if(fill_color != undefined && fill_alpha != undefined) sourceObj.endFill();};//------------------------------------------------------------------------------------------------------------//ChatUI.prototype.showStretcher = function(){ var o = this.owner; // the grid // hide the mouse, attach and show the cursor Mouse.hide(); if (o.stretcher == undefined) o.attachMovie("ResizeIcon", "stretcher", 30100); if(this.symbolName == 'userList') o.stretcher.gotoAndStop('horizontal'); else if(this.symbolName == 'inputTextArea') o.stretcher.gotoAndStop('vertical'); // place the cursor at the mouse o.stretcher._x = o._xmouse; o.stretcher._y = o._ymouse; o.stretcher._visible = true; // add a mouseMove for owner to get the cursor to follow the mouse o.onMouseMove = function() { stretcher._x = _xmouse; stretcher._y = _ymouse; updateAfterEvent(); }};ChatUI.prototype.hideStretcher = function(){ this.owner.stretcher._visible = false; delete this.owner.onMouseMove; Mouse.show();};//---resize_line_mc_onPressChatUI.prototype.resizer_onPress = function(){ var o = this.owner; // make the bar, synch to the mouse o.createEmptyMovieClip('stretchBar', 30050); o.stretchBar.clear(); if(this.symbolName == 'userList') { o.chatUI.drawRect(0,0,o.chatUI.DRAG_FRAME_THICKNESS/2,Stage.height, 0,o.chatUI.DRAG_FRAME_COLOR,100, o.chatUI.DRAG_FRAME_COLOR,100, o.stretchBar); o.stretchBar._x = o._xmouse; this.oldX = o.stretchBar._x; } else if(this.symbolName == 'inputTextArea') { o.chatUI.drawRect(0,0,Stage.width,o.chatUI.DRAG_FRAME_THICKNESS/2, 0,o.chatUI.DRAG_FRAME_COLOR,100, o.chatUI.DRAG_FRAME_COLOR,100, o.stretchBar); o.stretchBar._y = o._ymouse; this.oldY = o.stretchBar._y; } o.stretchBar._visible = true; var symName = this.symbolName; // keep the bar in synch with the mouse o.onMouseMove = function() { stretcher._x = _xmouse; stretcher._y = _ymouse; if(symName == 'userList') { var min_width = this.chatUI.settings.layout.userList.minWidth; if (min_width == -1) min_width = Stage.width * 0.1; if(this.chatUI.userListPosition == this.chatUI.USERLIST_POSITION_RIGHT) { var min_w = Stage.width - min_width - this.chatUI.SPACER; var max_w = this.chatUI.layoutLeftPaneMinWidth; stretchBar._x = Math.min(Math.max(_xmouse, max_w), min_w); } else if(this.chatUI.userListPosition == this.chatUI.USERLIST_POSITION_LEFT) { var min_w = min_width + this.chatUI.SPACER; var max_w = this.chatUI.layoutLeftPaneMinWidth; stretchBar._x = Math.max(Math.min(_xmouse, Stage.width - max_w), min_w); } } else if(symName == 'inputTextArea') { var min_height = this.chatUI.inputTextAreaPane.content_obj.minHeight; if (min_height == undefined) min_width = Stage.height * 0.1; if(this.chatUI.optionPanelPosition == this.chatUI.OPTIONPANEL_POSITION_BOTTOM) { var min_h = Stage.height - min_height - this.chatUI.SPACER; var max_h = Stage.height - Stage.height / 2; stretchBar._y = Math.min(Math.max(_ymouse, max_h), min_h); } else if(this.chatUI.optionPanelPosition == this.chatUI.OPTIONPANEL_POSITION_TOP) { var min_h = min_height + this.chatUI.SPACER + this.chatUI.preff_op_top_y; var max_h = Stage.height / 2; stretchBar._y = Math.max(Math.min(_ymouse, max_h), min_h); } } updateAfterEvent(); }};//---resize_line_mc_onReleaseChatUI.prototype.resizer_onRelease = function(){ var o = this.owner; if(this.symbolName == 'userList') { var percent = Stage.width / 100.0; if (o.chatUI.userList_XScale == undefined) { if(o.chatUI.settings.layout.userList.relWidth != -1) o.chatUI.userList_XScale = o.chatUI.settings.layout.userList.relWidth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -