2013/10/03

Flash AS3 TextFieldのサイズに合わせて自動でフォントサイズを変更

Flash Actionscript 3でTextFieldのサイズに合わせてフォントサイズを自動変更する方法を紹介


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
function autoTextSize(txt:TextField):void 
{
 var f:TextFormat = txt.getTextFormat();
   f.size = 30; // Set the max font size
  
 while ( txt.textWidth > txt.width|| txt.textHeight > txt.height) 
 {   
  f.size = int( f.size ) - 1;    
             txt.setTextFormat( f );  
   }
}

http://snipplr.com/view/47474/

0 件のコメント:

コメントを投稿