• 【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);
            }
        }
    }
  • 相关阅读:
    Codeforces Round #609 (Div. 2)---C. Long Beautiful Integer
    Codeforces Round #609 (Div. 2)--B.Modulo Equality
    J
    G
    Convoy
    Farming Mars
    Java indexOf() 方法
    request.getContextPath()得到的是什么路径?
    OLAP、OLTP的介绍和比较
    Book recommendation
  • 原文地址:https://www.cnblogs.com/kingfly/p/2573096.html
Copyright © 2020-2023  润新知