/ Published in: ActionScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class nl.mopics.utils.AlignFunc { public static function autoAdjustFontSize2Rect( txt:String, tff:TextFormat, desiredSize:Number, minimumSize:Number, tf:TextField, rect:Rectangle ):Void { tf._x = rect.x; tf._y = rect.y; tf._width = rect.width; tf.multiline = true; tf.autoSize = true; tf.text = txt; tff.size = desiredSize; for( var s:Number = desiredSize; s>minimumSize; s-- ) { if( tf._height < rect.height ) { break; } tff.size = s; tf.setNewTextFormat( tff ); tf.text = txt; } } }