zoukankan      html  css  js  c++  java
  • 【AS3代码】模拟聊天输入的逻辑

    package
    {
        import flash.display.Sprite;
        import flash.events.KeyboardEvent;
        import flash.text.TextField;
        import flash.text.TextFieldType;
        import flash.text.TextFormat;
        
        public class Main extends Sprite
        {    
            var myinput:TextField;
            
            public function Main():void
            {
                init();
            }
            private function init():void
            {
                var inputFormat:TextFormat = new TextFormat();
                inputFormat.size = 14;
                
                myinput = new TextField();
                myinput.type = TextFieldType.INPUT;
                myinput.defaultTextFormat = inputFormat;
                myinput.x = 10;
                myinput.y = 10;
                myinput.height = 20;
                myinput.width = 200;
                myinput.border = true;
                this.addChild(myinput);
                stage.focus = myinput;        
                
                myinput.addEventListener(KeyboardEvent.KEY_DOWN, checkForReturn);
            }
            
            public function checkForReturn(e:KeyboardEvent):void
            {
                if(e.charCode == 13)
                {
                    acceptInput();
                }
            }
            
            public function acceptInput():void
            {
                var theInputText:String = myinput.text;
                trace(theInputText);
                myinput.text = "";    //清空输入框中的文字
                //this.removeChild(myinput);
            }
        }
    }
  • 相关阅读:
    【Android平台安全方案】の #00-请不要在外部存储(SD卡)加密存储的敏感信息
    本学习笔记TCP/IP传输协议
    iOS_23_undress Girl
    uva 1560
    IOS开发-Swift新语言初见
    39个让你受益的HTML5教程
    ubuntu12.04管理员账户登录不了桌面,仅仅能客人会话登录
    怎样使用SetTimer MFC 够具体
    ArcGIS API for Silverlight 编辑Geometry
    几种更新(Update语句)查询的方法
  • 原文地址:https://www.cnblogs.com/kingfly/p/2573096.html
Copyright © 2011-2022 走看看