Wednesday, April 6, 2011

TextField() sometimes stays BOLDING even when HTML style was reset with setTextFormat()

any ideas why TextField() sometimes keeps BOLDING ( even when format was reset with setTextFormat() like this:

myFormat.bold=false;
defaultTextFormat =myFormat;  
defaultTextFormat.bold = false;
setTextFormat(myFormat);

htmlText("this is bold even when should not")

PS: Textfield is editable and problem occurs when its edited by user

UPDATE: I want to get rid of all formatting to avoid unwanted BOLD, textfield has a bug that when bolded word is backspaced by user, everything in textfield is bolded for ever.

From stackoverflow
  • I believe that with the TextField control you need to set the TextFeild.styleSheet to change the HTML style. Try something like this:

    var myText:TextField = new TextField();
    var style:StyleSheet = new StyleSheet();
    var fonts:String = "Helvetica Neue, Arial, _sans";
    style = new StyleSheet();
    style.setStyle(".body", {fontFamily:fonts, fontSize:"12", fontWeight:"normal", color:"#222222", textDecoration:"none"});
    myText.styleSheet = style;
    myText.htmlText = "this is bold even when should not";
    

0 comments:

Post a Comment