0
votes

I have created a XML image gallery, which displays text in between each slide. Now I have created a movie clip with a dynamic text field (with Render HTML selected) to display the text from the XML which is pushed into an array. Now, this all works great BUT... /n or /r is not creating a new line break (as they need to be custom). Yet if I create an Array and manually push strings "Bla bla bla /n bla bla bla" I get a line break. I have tried converting the Array item to string (even though it already is), I would also avoid creating textField = new textField() any Ideas would be welcomed.

Cheers

3
Can you show your XML, and the trace of the xml before setting it to your textfieldPatrick
XML node is like this: <image imageFile="GrandOpening1.jpg" text="XXXXX \nXXXXXX\nXXXX XXXX XXXXXX"></image> trace of the .@text = XXXXX \nXXXXXX\nXXXX XXXX XXXXXXJono

3 Answers

1
votes

Since your TextField is HTML enabled, it would be better to use a <br> tag to create a new line break.

1
votes

Edit

You have two choices :

-as suggested put replace in your XML the \n by a <br/> but encoded to be a valid XML &lt;br/&gt;

<image imageFile="GrandOpening1.jpg"
       text="XXXXX&lt;br/&lt;XXXXXX&lt;br/&lt;XXXX XXXX XXXXXX">
</image> 

-or at runtime when filling your textfield replace the \n by a <br/>

[email protected]().split("\\n").join("<br/>");

/n /r is not correct it 's \n \r.

Have you enable multiline option for your TextField.

0
votes

\n \r only works in runtime and
won't work. I use a custom string to represent linebreak "#BR#" for example. Before you pass the string to the text box, replace all instances of "#BR#" with "\n" using regular expression.

var str:String = xmlString; var pattern:RegExp = /#BR#/ig;//target all instances of #BR#(case insensitive) txt_textbox.text=str.replace(pattern, "\n");