【问题标题】:As3 Text Manipulation - How to say "if charAt == Carriage Return"?As3 文本操作 - 怎么说“如果 charAt == 回车”?
【发布时间】:2013-06-28 14:32:30
【问题描述】:

我目前有一个基于两个文本字段禁用发送按钮的表单。一个字段是一个消息框。我想拥有它,这样一个人就不能只放一堆入口和空间。我目前检查空格,但 charAt 只返回一个空格:/ 这是我希望它的样子:

        _sendComposeBtn.visible = true;

              // if the length of the message is zero, don't let people send it
        if (_messageLength == 0)
        {
            trace("hiding");
            _sendComposeBtn.visible = false;
            _realMessage = false;
        }


        _allSpaces = true;
              // start with allSpaces true. If there is a nonspace (or non-enter character then hide send button                
        for (i = 0; i < _bigMessageTextField.length; i++)
        {
            if (_bigMessageTextField.text.charAt(i) != " " && _bigMessageTextField.text.charAt(i) != (ENTER_CHARACTER))
            {
                trace("not a space");
                _allSpaces = false;
            }
        }

        if (_allSpaces == true)
        {
            _sendComposeBtn.visible = false;
        }

【问题讨论】:

    标签: text flash-builder flash-cs5 actionscript-3


    【解决方案1】:

    你可以说:

    _bigMessageTextField.text.charAt(i) != String.fromCharCode(13)
    

    【讨论】:

    • @Fans 你应该接受这个答案,因为它对你有用并且是正确的。
    • 我的水平不够高。给我一些稀有的糖果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 2021-07-16
    • 2022-11-16
    • 1970-01-01
    • 2015-03-30
    • 2011-04-25
    • 1970-01-01
    相关资源
    最近更新 更多