Thanks a lot Manish. I wasn't even aware of the mx_internal thing. It
 works great for what I need. However, I do have doubts that this is
the most elegant solution.

I don't know how your subclassed idea could work. Because in the
subclass itself you are setting the styleSheet to the Text object, I
don't know how is that different from what I tried to do. Also, if I
subclass the Text, then I have to use it only programatically or can I
use it in mxml, drag it visualy on stage, etc.?  

Cheers
Alen

--- In flexcoders@yahoogroups.com, "Manish Jethani"
<[EMAIL PROTECTED]> wrote:
>
> On 5/5/07, b_alen <[EMAIL PROTECTED]> wrote:
> > 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 Flex too you can do it in the Flash way, i.e. by setting the
> styleSheet property.
> 
>   import mx.core.mx_internal;
> 
>   myTextObject.mx_internal::styleSheet = myStyleSheetObject;
> 
> Note: The styleSheet property in Label and Text is in the mx_internal
> namespace -- it's not public API. I guess this is due to the
> inconsistency between Flash and Flex styling. If you don't want to use
> mx_internal, you can do it by making a subclass of Text.
> 
>   public MyText extends Text {
>     public function setStyleSheet(styleSheet:StyleSheet):void {
>       textField.styleSheet = styleSheet;
>     }
>     public function getStyleSheet():StyleSheet {
>       return textField.styleSheet;
>     }
>   }
>


Reply via email to