Connecting Tech Pros Worldwide Forums | Help | Site Map

how can I create a line break in a flash string?

Newbie
 
Join Date: Oct 2007
Posts: 1
#1: Oct 6 '07
I am calling to a large string that is separate paragraphs. I just don know how to put line breaks in flash actionscript. Can anyone help me?

example

tLabel.text = "blah blah blah blah (then a return with a tab indent) blah blah blah"

I just want my paragraphs to show up seperated when the text loads in the textField. Not to appear like one long string of on going sentences.

Thanks,

Nathan

xNephilimx's Avatar
Expert
 
Join Date: Jun 2007
Location: Buenos Aires, Argentina
Posts: 200
#2: Oct 8 '07

re: how can I create a line break in a flash string?


Hi f5leeba, welcome to TSDN!
To put line breaks use the special newline character \n where you want a line break. Also enable word wrapping and multiline, so it automatically wraps the text.

something like this (notice the \n):
Lorem ipsum dolor sit amet,\nconsectetuer adipiscing elit.

Will be renderd as this:
Lorem ipsum dolor sit amet,
consectetuer adipiscing elit.

Kind regards,
The_Nephilim

Quote:

Originally Posted by f5leeba

I am calling to a large string that is separate paragraphs. I just don know how to put line breaks in flash actionscript. Can anyone help me?

example

tLabel.text = "blah blah blah blah (then a return with a tab indent) blah blah blah"

I just want my paragraphs to show up seperated when the text loads in the textField. Not to appear like one long string of on going sentences.

Thanks,

Nathan

Newbie
 
Join Date: Nov 2007
Posts: 1
#3: Nov 2 '07

re: how can I create a line break in a flash string?


this does not seem to work.

my string comes up as something\nsomething

has this been tested with htmlText texfields?

PS I cant use <br> as my text comes from an xml file and adding <br> there breaks the XML tags.

using flash CS3 actionscript3



Quote:

Originally Posted by xNephilimx

Hi f5leeba, welcome to TSDN!
To put line breaks use the special newline character \n where you want a line break. Also enable word wrapping and multiline, so it automatically wraps the text.

something like this (notice the \n):
Lorem ipsum dolor sit amet,\nconsectetuer adipiscing elit.

Will be renderd as this:
Lorem ipsum dolor sit amet,
consectetuer adipiscing elit.

Kind regards,
The_Nephilim

Familiar Sight
 
Join Date: Jul 2007
Location: France
Posts: 149
#4: Nov 2 '07

re: how can I create a line break in a flash string?


Quote:

Originally Posted by uncleunvoid

this does not seem to work.

my string comes up as something\nsomething

has this been tested with htmlText texfields?

PS I cant use <br> as my text comes from an xml file and adding <br> there breaks the XML tags.

using flash CS3 actionscript3

Check out this link on using CDATA in XML, then you can add <br> to an htmlText textFIeld.


http://www.w3schools.com/xml/xml_cdata.asp
Newbie
 
Join Date: Oct 2008
Posts: 1
#5: Oct 31 '08

re: how can I create a line break in a flash string?


you could also use \r\n, which adds a paragraph break, rather than a new line break.

Hoped this helped!
Reply