Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3633694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:41:07+00:00 2026-05-19T00:41:07+00:00

i have a problem where i want to remove the last character from a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:41:08+00:00Added an answer on May 19, 2026 at 12:41 am

    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 set textField.text, you can still get xml formatted text to work with:

    textField.text = "A test.";
    trace (textField.htmlText);
    

    will actually return:

    <P ALIGN="LEFT"><FONT FACE="Times Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">A test.</FONT></P>
    

    Text will always appear within <FONT> tags reflecting the changes you made using setTextFormat(). You can, therefore, iterate over the XML contained in this line, and remove only the last character in the last TextNode:

    private function removeLastCharacter (textField:TextField) : void {
        var xml:XML = new XML (textField.htmlText);
        for ( var i : int = xml.children().length()-1; i >= 0; i-- ){
            var node:XML = xml.children()[i];
            if ( node.name() == "FONT") {
                var tx:String = node.text()[0].toString();
                node.setChildren (tx.substr (0, tx.length-1));
                break;
            }
        }
        textField.htmlText = xml; 
        trace (textField.text); // In the above example, output will be: "A test";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
with my RCP program I have the problem that I want to have more
I have a problem and I want to implement the MVC pattern to my
I have problem with return statment >.< I want to store all magazine names
I have problem with HTTP headers, they're encoded in ASCII and I want to
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
The Problem I want to press a key when I have a line highlighted
I have a little Java problem I want to translate to Python. Therefor I
I have a small problem where I want to find the next active item
I have a problem but first i want to know if im working on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.