Skip to main content
December 23, 2009
Question

htmlText Auto formatting textfield

  • December 23, 2009
  • 1 reply
  • 721 views

how could we remove auto tag adding by htmlText Property because when we apply htmlText for a textfield it automatically add <p> and <font> tag.

In my project i am saving one textfield property <p align='right'> in server but when i am assigning this value from server its changing to <p align='left'>.

So how could we remove this auto formatting by htmlText??

As in http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html link there is written also "When its htmlText property is traced, the output is the HTML-formatted String, with additional tags (such as <P> and <FONT>) automatically added by Flash Player."

i want to remove this auto adding tag. Please help me out.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 23, 2009

are you trying to remove all html tags from an html-enabled textfield?

if so, save the text property of the textfield, dis-able the html property of the textfield and assign the saved text to the textfield.

December 23, 2009

Hy thanks K for so fast reply,

     No, i am basically making an editor kind of thing, where some text have align=left property and some have align=right property. So while saving i am checking alignment of the text and applying in <p> tag. Suppose i saved <p align="right">Text Sample</p> now i called this string from server and applied to my TextField. Now when i am assigning this text to textfield (mytext.htmlText = someServerVariable) then its coming as <p align="left">Text Sample</p>.

Some tags of font is also there which i ignored here. i just want to put same string in html text. i want to remove auto formatting property of
htmlText.

kglad
Community Expert
Community Expert
December 23, 2009

if you want to replace <p align="left"> with <p align="right">, you can use:

var re:RegExp = /<p align="left">/;
var s:String = someServerVariable;
s.replace(re, '<p align="right">');