Dynamic Text Area
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
