在输入时删除TextInput内部的字符? (Flex 4.5)

| 我希望在用户输入时删除Spark TextInput中的特定字符,而不会引起任何干扰,例如在最后一个字符之后用鼠标舔等。 任何建议表示赞赏。     
已邀请:
        您可以创建自己的自定义TextInput组件并覆盖
keyDownHandler()
,也可以在
TextInput
上添加事件监听器,如下所示:
<s:TextInput keyDown=\"{ textInputKeyDownHandler(event) }\"/>
然后在事件处理程序上:
private function textInputKeyDownHandler(event:KeyboardEvent):void {
    // Make your validations and if necessary, use the following command 
    // to prevent the character from being added to the TextInput
    event.preventDefault();
}
这样,字符将永远不会添加到
TextInput
,这意味着text属性和光标位置不会改变。 注意:使用ѭ5和ѭ6进行必要的验证。     
        您是否尝试过限制TextInput的属性?我不知道您的具体字符是什么,但通常有2种限制条件。 限制为一组字符:
<s:TextInput restrict=\"A-Za-z\" />
允许除某些特殊字符外的所有字符:
<s:TextInput restrict=\"^0-9\" />
要处理Unicode字符,请使用\\ u:
<s:TextInput restrict=\"\\u0239\" />
    

要回复问题请先登录注册