I've been asked to create an FT that I cannot figure out.
I would normally send a persons name as a single variable, lets call that variable f1.
I'd then use this function to make the font fit into the space provided
Code: Select all
private static function ScaleDownTextField(Input:String, Field:TextField):void
{
var wi:int = Field.width;
var xcoord: int = Field.x;
Field.autoSize = TextFieldAutoSize.CENTER;
Field.text = Input;
if (wi < Field.width)
{
Field.scaleX = wi / Field.width;
Field.x = xcoord;
}
}
followed by this to apply the function to the text box:-
override public function SetData(xmlData:XML):void
{
for each (var element:XML in xmlData.children())
{ if (element.@id == "f1")
{
ScaleDownTextField(element.data.@value, Text1.f1);
}
}
}
What I need to do is take the Forename and Surname and split them so that they can be a different weighted and sized font.
I think I can split the variable based upon the space, I think I can then create a new text box for the surname at the physical end of the forename and set its font, I just cant get my head round how and I'm having a but of a brain freeze.
Can anyone help?