views:

156

answers:

1

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.

A: 

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.

Richard Inglis
Richard,So sorry -- somehow I didn't see your answer. I'm back to wrestling with this. Yes, I am embedding fonts. The moment I change ’italic’ to ’normal’ in the stylesheet, everything is blank. I tried adding a new non-italic font (Geneva instead of Arial) to see if it would recognize that. I tried specifying font-family; I tried using the ‘important’ directive; I tried resetting the existing italic font to a non-italic font. I tried removing all embedded fonts and just setting font-family:Arial, Helvetica, sans-serif; in the stylesheet. None of this worked.
David