I´m trying to vertical align some text in a Monoline TextField in AS3. Not sure if this can be done with TextFormat, but I don´t think so.
I´ve looked for a solution
This works great only for the case that the text is in single line.
First you have to add an initial break line in every text. I did it in a new component extending TextField and overriding the "text" function, adding the initial break line character.
import flash.text.TextField;
public class MyTextField extends TextField
{
public function MyTextField()
{
super();
}
public override function set text(value:String):void
{
value = "\n" + value;
super.text = value;
}
}
Then you need to apply format to the text, an use the "leading" property that represents the amount of vertical space between lines.
myTextFormat = new TextFormat();
// This is the existent horizontal align
myTextFormat.align = TextFormatAlign.CENTER;
// This is my simulated vertical align. Remember that the first character
// is always a break line. In most cases it will be a negative value...
myTextFormat.leading = -22;
var myTextField:MyTextField = new MyTextField();
myTextField.text = "Hello";
myTextField.setTextFormat(myTextFormat);
I hope this will help to someone who needs vertical align in single line text using TextField. :-)