开发者

Rendering HTML text with an HTML tag with a 'style' attribute

开发者 https://www.devze.com 2023-03-26 08:57 出处:网络
I am using a spark RichText component to render a html text in my Flex Web Application. The html text that is given to me is with HTML elements with \'style\' attribute having all the styles.

I am using a spark RichText component to render a html text in my Flex Web Application. The html text that is given to me is with HTML elements with 'style' attribute having all the styles. For Example:-

<p style="text-align: left;"><b>Hello</b> <i>this is a sample</i>
<font style="color: #ff0000;">HTML text</font></p><p style="text-align: right;">
<u>to be rerndered in FLEX</u></开发者_JS百科p>

Now, the Flex spark RichText does not show all these styles applied to the text.

However, if I have HTML with inline property attributes (without 'style' attribute) e.g. :-

<font color="#ff0000">Hello</font>

With the above, I get the desired style.

Any pointers/ solution to get around with this, and render the styles will be appreciated.

Thanks,

Mangirish


Try using <span style="color:#FF0000;">HTML text</span> and see if that makes any difference? I'm not too sure how well Flex renders older HTML tags. Besides, <font> is deprecated anyway.


If your css is fix, you can use StyleSheet Object

Here is a tutorial : http://learnola.com/2008/12/03/actionscript-3-tutorial-using-html-and-css/

If you need more information, just ask it in comments.


Short answer, TLF won't support that kind of styles that I know of, but you can always try to convert it to see what happens:

var textflow:TextFlow = TextConverter.importToFlow(yourHTMLString, TextConverter.TEXT_FIELD_HTML_FORMAT);

However, I have a sneaking suspicion that it won't convert the style properly and probably just ignore it altogether. The only solution I can think of is

  1. Have a custom way to parse the html and get the style out and set it on the textflow or
  2. Have the 'server' html be fixed to be compatible with the flex TLF (inline styles)

I would personally prefer the second option since it's easier to implement on the client.

0

精彩评论

暂无评论...
验证码 换一张
取 消