The following example shows how you can set a custom text format on a Flash ActionScript 3.0 TextInput component by setting the textFormat style to a TextFormat object.
Full code after the jump.
// ActionScript 3.0 /* Requires: * - TextInput component in Flash library */ import fl.controls.TextInput; var textFmt:TextFormat = new TextFormat(); textFmt.color = 0xFF0000; textFmt.font = "Courier New" textFmt.size = 18; var textInput:TextInput = new TextInput(); textInput.text = new Date().toString(); textInput.setStyle("textFormat", textFmt); textInput.width = 300; textInput.move(10, 10); addChild(textInput);
{ 3 comments… read them below or add one }
Can one vertically align text within a textinput field to the middle or the vertical center of the box? I have a textinput that I resized the height but the text stays in the upper left corner, which is pretty ugly. Any help you can give is very much appreciated.
Awesome :D! Just what I was looking for :)! Thanks for sharing, Peter :)!
This website is so useful :D! I love your posts!
Ok, if I want to get my text formatted a certian way but I already have a bunch of different text boxes with different text on different keyframes, how do I copy the style of the text in one box and apply it to the next so I don’t have to keep changing the color on each text box. Is there a way to copy just the attributes of a text box?