Reputation: 280
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
Upvotes: 0
Views: 2292
Reputation: 2310
\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");
Upvotes: 0
Reputation: 15717
Edit
You have two choices :
-as suggested put replace in your XML the \n
by a <br/>
but encoded to be a valid XML <br/>
<image imageFile="GrandOpening1.jpg"
text="XXXXX<br/<XXXXXX<br/<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.
Upvotes: 1
Reputation: 999
Since your TextField is HTML enabled, it would be better to use a <br>
tag to create a new line break.
Upvotes: 1