开发者

Flash CS4/AS3 Dynamic Text Box

开发者 https://www.devze.com 2022-12-23 21:40 出处:网络
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

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


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


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/>

myTextField.htmlText=xml.@text.toString().split("\\n").join("<br/>");

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

Have you enable multiline option for your TextField.


\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");

0

精彩评论

暂无评论...
验证码 换一张
取 消