actionscript 3 - AS3 Scale Text Function Causing Conflict With Textfield HTML Format -


hello guys using below function scale dynamic font size @ run time thus:

function scaletexttofitintextfield( txt : textfield ):void{  var f:textformat = txt.gettextformat();  f.size = ( txt.width > txt.height ) ? txt.width : txt.height;  txt.settextformat( f );   while ( txt.textwidth > txt.width - 4 || txt.textheight > txt.height - 6 ){                    f.size = int( f.size ) - 1;     txt.settextformat( f ); } }  scaletexttofitintextfield( tf ); // tf dynamic multiline textfield on stage dimension 150x150 

the idea when textfield populated external content, reduces font size fit text texfield. work far.

my biggest problem function interferes textfield html formatting. instance; load external html:

<font size="-2">this text way</font><br><font size="+5">too big</font><br>to fit in box, i'll give try! 

with scale function applied textfield, html formatting (size variations) not work, if remove scale function, does.

ideally, want able scale font if text fit , able apply html format well.

somebody pls help. using cs5

many thanks.

it may work if wrap htmltext in <![cdata[]]>:

<![cdata[<font size="-2">this text way</font><br><font size="+5">too big</font><br>to fit in box, i'll give try!]]> 

otherwise, try wrapping textfield in sprite , scale sprite instead? how scale dynamic textfield in flash center point using as3?


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -