i have a problem where i want to remove the last character from a textfield (including linebreaks) that has multiple textformats without removing the formats.
so far i have:
textfield.replaceText(textField.length-1,textField.length-1,'');
i guess this doesn’t remove linebreaks, and is very slow, seems to destroy my textformats.
or:
textfield.text = textfield.text.slice(0,-1);
this is faster but removes all textformats as well.
It is a bit tedious, but you can use the
htmlText-property of TextField, even though you are not formatting your text with StyleSheets: Flash will transform all your formatting information into HTML text internally, so even though you settextField.text, you can still get xml formatted text to work with:will actually return:
Text will always appear within
<FONT>tags reflecting the changes you made usingsetTextFormat(). You can, therefore, iterate over the XML contained in this line, and remove only the last character in the last TextNode: