0
votes

I've inherited a project written in AS2. It programatically creates textfields and populates them. It refers to a stylesheet, and in that stylesheet is font-style:italic;

Everything shows in italic just fine. But I've been asked to change it to normal. WHen I change it to font-style:normal; in the stylesheet, the text disappears. And in the code, it refers to htmlText as the property of the textfield.

Anyone know what this could be due to? At first I was thinking maybe embed the font, but if a style is being applied and it's htmlText wouldn't that be unnecessary?

Thanks.

1

1 Answers

0
votes

I tried to reproduce your problem...

// populate some text fields...
var myList:Array = new Array("<p><b>hello</b> world</p>", "<p>goodbye <i>cruel</i> world</p>");
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
myStyle.parseCSS("p {font-style:italic;}");
var myField:TextField;
for (var i:Number = 0; i<myList.length; i++) {
    myField = this.createTextField("myText"+i, this.getNextHighestDepth(), 100, 50+i*50, 300, 40);
    myField.html = true;
    myField.styleSheet = myStyle;
    myField.htmlText = myList[i];
}

//now click to switch from italic to normal
this.onMouseUp = function() {
    if (myStyle.getStyle("p")['fontStyle'] == "italic") {
        myStyle.parseCSS("p {font-style:normal;}");// all normal (except 'cruel')
    } else {
        myStyle.parseCSS("p {font-style:italic;}");// all italic
    }
}

... but it seems to work fine for me. Is there anything extra that you're doing with your TextFields, like embedding fonts or anything?

A quick google shows lots of similar-sounding issues when trying to embed fonts for html textFields.

Hope this helps.