I have a string that goes somthing like this: var str:String = "<p class=\"H1\">section</p>"; var str:String += "<p class=\"TXT\">main text</p>";
and then I populate the Text component like this: txtPage.htmlText = str; Now, I want to add styles to this text through class attributes that I provided in the HTML. In Flash 8 this is pretty straightforward but I couldn't figure out how to do it in Flex. In Flash I would create a StyleSheet, then add some styles with setStyle(), and finaly assign a StyleSheet to TextField. In Flex, I tried something similar but it didn't work. I did this: var style:StyleSheet = new StyleSheet(); style.setStyle(".H1",{fontWeight:"bold"}); style.setStyle(".TXT",{color:"#FF0000"}); txtPage.styleName = style; It didn't work, then I tried: var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration(); newStyleDeclaration.setStyle(".TXT", {color:"#FF0000"}); newStyleDeclaration.setStyle(".H1", {fontWeight:"bold"}); StyleManager.setStyleDeclaration(".style1", newStyleDeclaration, true); txtBook.styleDeclaration = newStyleDeclaration; // didn't work txtBook.styleDeclaration = StyleManager.getStyleDeclaration(".style1"); // didn't work Then finally I tried this: txtPage.setStyle(".H1",{fontWeight:"bold", textAlign:"center"}); txtPage.setStyle(".TXT",{color:"#FF0000"}); For all the options I tried both the ".H1" and the "H1" style syntax (with and without the dot). I think I'm missing the obvious here. I'm sure it can't be too complicated. Thanks. Alen