Skip to main content
Participant
December 17, 2012
Question

Dynamic Text Area

  • December 17, 2012
  • 1 reply
  • 996 views

Hi EveryOne,

Due to font rendering issues in flex 3, I've decided to create a custom dynamic TextArea because my App consists of different languages. So in creationComplete Handler, Im calling a method like this

{

var str:String = htmlTextModification(super.text);

this.htmlText = str;

}

private function htmlTextModification(value:String):String

                    {

                              var valueRequired:String = "";

                              var valueLine:String = "";

                              var beggingSpaceIndex:int=0;

                              var endingSpaceIndex:int;

                              for(var i:int = 0;; i++)

                              {

                                        endingSpaceIndex = value.indexOf(" ", beggingSpaceIndex);

                                        if(endingSpaceIndex!=-1)

                                        {

                                                  valueLine+= value.substring(beggingSpaceIndex,endingSpaceIndex) + " ";

                                                  this.text = valueLine ;

                                                  this.validateNow();

                                                  if(this.textWidth < this.width-10)

                                                  {

                                                            valueRequired+= value.substring(beggingSpaceIndex,endingSpaceIndex)+ " ";

                                                            beggingSpaceIndex = endingSpaceIndex + 1;

                                                  }

                                                  else

                                                  {

                                                            valueRequired+= "<br>" + value.substring(beggingSpaceIndex,endingSpaceIndex)+ " ";

                                                            valueLine = "";

                                                            valueLine+=value.substring(beggingSpaceIndex,endingSpaceIndex)+ " ";

                                                            beggingSpaceIndex = endingSpaceIndex + 1;

                                                  }

                                        }

                                        else

                                        {

                                                  break;

                                        }

                              }

                              return valueRequired;

                    }

So that we can be setting the breaks in the text whenever the string width crosses the width of text area.

But calling validateNow() is a heavy process, is what I heard.

Is there a work around instead of validateNow(), I just want to calculate textWidth?. More Over I dont want this code in creationHandler. Is that also possible ? Thanks

This topic has been closed for replies.

1 reply

Vikram_S
Known Participant
December 17, 2012

Hello AGNIVESH,

Have you tried Text Layout Framework. This framework provide us(Developers ) more control on text Engine of flex.

Thanks,

Vikram