Return to Snippet

Revision: 8916
at October 14, 2008 03:31 by Paco


Updated Code
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;
		}
	}
	
}

Revision: 8915
at October 14, 2008 03:30 by Paco


Initial Code
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.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;
		}
	}
	
}

Initial URL


Initial Description


Initial Title
Autoadjust fontsize to a rectangular boundry

Initial Tags


Initial Language
ActionScript