As3 Text Manipulation - 如何说“if charAt == Carriage Return”?

时间:2013-06-28 14:32:30

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

我目前有一个基于两个文本字段禁用发送按钮的表单。一个字段是一个消息框。我希望拥有它,以便一个人不能只是放入一堆进入和空间。我目前检查空格,但是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;
        }

1 个答案:

答案 0 :(得分:0)

你可以说:

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