PDA

View Full Version : how do I add line breaks to text fields?



Shaedo
June 11th, 2009, 02:24 AM
I have a string (from xml) I want to display on stage. Currently I have a text field that I am simply assigning the text to (no problems) but I want to add line breaks at certain points.after reading this line:

"If the text includes a line break (for example, "\n" or "\r"), the bottom is also resized to fit the next line of text."

found here:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/text/TextField.html#autoSize

I got the impression that I could add a string to text with a line break in it? If I try and add it to my xml file it simply writes it out as normal characters.

I am fairly sure I can do it by showing as HTML but was wondering if there was another way ?

Thanks for any help!

.ral:cr
June 11th, 2009, 02:35 AM
with CDATA. i always forget how is written, something like this: <[CDATA[line1\nline2]]>

if you don't want your textfield to be resized with the text you have to remove the autoSize property

Shaedo
June 11th, 2009, 03:14 AM
thank you .ral:cr, good tip!

I ended up using the cdata stuff (good explanation by senocular here http://www.kirupa.com/web/xml/XMLbasics6.htm) to at least allow me to add <br> tags to my xml derived string without flash having a fit. So I am achieving the result I wanted.

thanks again!