views:

633

answers:

2

Hi i have TextField in as3 in that i assigning the html value like

var TFhtmlText:String = <span class='Header'>The value need to be 25 percentage  \n and percentage be 50 percent.</span>

 txtField.htmlText = TFhtmlText;

from the above i need line break after 25 percentage for that i used <br/> but i got unwanted spaces between line break, so that now i used &#xD; for linebreak this is working fine , so i need to replace this (&#xD;) character where \n is present .. i tried with

TFhtmlText = TFhtmlText.split('\n').join('&#xD;')
 txtField.htmlText = TFhtmlText;


TFhtmlText=TFhtmlText.replace(/\n/g, "&#xD;");

But not working ....how can i achieve it

thanks in advance

A: 

Next time please format your code correctly, it's difficult to read.

Assuming I read it correctly, you want to write your string as follows. Replace the \n with
and remove the whitespace around it.

var TFhtmlText:String = "The value need to be 25 percentage<br/>and percentage be 50 percent."
txtField.htmlText = TFhtmlText;
Rhysyngsun
A: 

What about this:

var my_str:String = new String(TFhtmlText);
my_str = my_str.split('\n').join('&#xD;');
txtField.htmlText = my_str;
Makram Saleh