2

How do you make some parts of spark.components.RichText bold?

In my Flash / ActionScript 3 programm I have been just using htmlText property of a TextField, and set it to 1 2 <b>3</b> - but now I'm trying to port my program to Flex 4.5.

UPDATE:

I'm trying:

myRichtText.textFlow = TextConverter.importToFlow('1 2 3 <s:span fontWeight="bold">4 5</s:span>', TextConverter.TEXT_LAYOUT_FORMAT);

but nothing is displayed. I'd prefer not to use RichEditableText or TextArea.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

4 Answers4

2
 var str:String=rc.text.toString().substr(2,1);
 var str2:String=rc.text.toString().substr(0,2);
         str=str2+"<b>"+str+"</b>";
         rc.textFlow = TextConverter.importToFlow(str, TextConverter.TEXT_FIELD_HTML_FORMAT);

Rich Text

<s:RichText id="rc" text="123"/>

I tried out this way.. In str you should have your html text in this case 12<b>3</b> You can try it by different methods like link provided by Mitul Golakiya.. hope this will help you...

Santhosh Nayak
  • 2,312
  • 3
  • 35
  • 65
0

Here is the solution for it...

You should use TextConverter.importToFlow()...

http://blog.flexexamples.com/2009/10/06/displaying-html-formatted-text-in-a-spark-richtext-control-in-flex-4/

Mitul Golakiya
  • 402
  • 4
  • 20
0

You may want to use RichEditableText, which has the method setFormatOfRange().

FTQuest
  • 546
  • 3
  • 3
0

Do this :

myRichtText.textFlow = TextConverter.importToFlow('1 2 3 <b>4 5</b>',  TextConverter.TEXT_FIELD_HTML_FORMAT);
pradeek
  • 21,445
  • 2
  • 31
  • 32