• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Detecting Line Breaks in htmlText

Explorer ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

I know you can identify line breaks when working with text files by checking the character equivalent, but is this possible to do with htmlText?

I am making a text editor for my client and I am using the textArea component as the input field with the data stored in an XML. All's well, except for the line break--the textArea is rendered as htmlText so that the client will be able to see the changes made instantly. By default, it works, but the spacing is all screwed up (indents, double-spaces at times), so I decided to condense the whitespace. With this on, it gets rid of the spacing issues since the html is being rendered exactly as coded. The thing is, hitting enter in the textArea does not add <br /> to the htmlText code.

Do i need to overwrite the Enter key with a custom function that inserts a ine break when using the textArea, or is there a way to detect and convert these line breaks in htmlText?

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 10, 2009 Oct 10, 2009

don't you see </P><P.. when the enter key is used?

Votes

Translate

Translate
Community Expert ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

don't you see </P><P.. when the enter key is used?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

Oh, yeah! Another one to the dumb list. I stripped the p tags along with

theautomatically generated tags that I thought were unnecessary and just

bloating the data file (face, letterspacing, etc). I guess I oversimplified

the html data and it slipped my mind that p's around for htmlText line

breaking, so I kept looking for \n, brs, etc.

It's almost amusing to find myself getting stuck every now and then over the

smallest of problems with carelessness as the culprit. Thank you for

knocking some sense into my tired head. I think I need to get some rest and

fresh air.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

you're welcome.

(and i thought i've made every error possible with flash and then yesterday i found a new one:  i wrote a function and when testing i got an "expect a right paranthesis before colon" error message.  it takes me several minutes of staring at the line of code cited to find i worte my whateverF() function like:

whateverF(e:Event){

blahblahblah

}

and forgot to prefix my function name with "function".  it seems there's no end to stupid mistakes, at least, for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

LATEST

I actually like encountering problems in flash and then solving it/finding a workaround, it gives a feeling of relief and accomplishment. It's just sad funny when you discover it's due to careless that you lost some good minutes/days/hours. Part of a developer's life I guess.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

Well.. I'm not sure i understand the problem..

As i understand you problem is, you need the textArea to input a '<br />' when you hit Enter?

Before you "save" the text in the textArea, convert all "\n\r" to "<br />".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2009 Oct 10, 2009

Copy link to clipboard

Copied

@kasper sørensen

looking for \n, \t, would work for text, but not for htmlText. You won't find it in the string, and the whole time I was looking to do that. While br is htmlText's line break, flash generates <p> instead, which also allows a line break. I didn't realize that because I also took out p tags when I stripped the text of unecessary tags.

Thanks to kglad for making me realize that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines