Actionscript 3 在as3中使用TextFormat在textField中隐藏字符

Actionscript 3 在as3中使用TextFormat在textField中隐藏字符,actionscript-3,Actionscript 3,我有一个文本字段和一个文本,我需要隐藏最后一个字符 我试过了 _textField.text = "My string"; var newtextFormat:TextFormat = new TextFormat(); newtextFormat.size = 0; _textField.setTextFormat(newtextFormat, _textField.length-1, _textField.length-1); 问题是,最后的特许权仍然

我有一个文本字段和一个文本,我需要隐藏最后一个字符

我试过了

    _textField.text = "My string";
    var newtextFormat:TextFormat =  new TextFormat();
    newtextFormat.size = 0;
    _textField.setTextFormat(newtextFormat, _textField.length-1, _textField.length-1);  
问题是,最后的特许权仍然像单个像素一样可见。 有没有办法将字体颜色设置为透明 比如说

newtextFormat.color = <any tranparent color>;
newtextFormat.color=;

我建议您将文本字段中的文本字符串替换为空白字段(“”),而不是更改大小或字母,如下所示:

_textField.text = "My string";
var newString:String=_textField.text.replace (_textField.text.charAt (_textField.text.length-1) , " ");

_textField.text =newString;
//now textField text is My strin
如果你想让它成为另一个角色,而不是最后一个角色,你可以很容易地将其更改为例如

_textField.text = "My string";
var newString:String=_textField.text.replace (_textField.text.charAt (3) , " ");

_textField.text =newString;
//now textField text is My  tring

您可以使用textfield的“限制”功能来确定可以键入哪些类型的字符。您可以收听“更改”事件并编辑他们键入的内容。

为什么不去掉最后一个字母<代码>\u textField.text=\u textField.text.substr(0,\u textField.text.length-1)如果文本后面是纯色,请保持原样大小,只需将文本格式更改为与背景相同的颜色。背景颜色不统一。。我会试试你的建议,但我怀疑它会破坏这本书的文本格式rest@user3264864-您不想使用替换方法。。。它将替换该角色的所有实例。您明确表示只想隐藏最后一个字符。如果要更改文本字段的实际文本,请使用我的注释中的代码。