User Guide
652 ActionScript classes
Example
The following code sets the _alpha property of a text field named my_txt to 20%. Create a
new font symbol in the library by selecting New Font from the Library options menu. Then
set the linkage of the font to
my font.Set the linkage for a font symbol to my font. Add the
following ActionScript to your FLA or ActionScript file:
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "my font";
// where 'my font' is the linkage name of a font in the Library
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 100,
22);
my_txt.border = true;
my_txt.embedFonts = true;
my_txt.text = "Hello World";
my_txt.setTextFormat(my_fmt);
my_txt._alpha = 20;
See also
_alpha (Button._alpha property), _alpha (MovieClip._alpha property)
autoSize (TextField.autoSize property)
public autoSize : Object
Controls automatic sizing and alignment of text fields. Acceptable values for autoSize are
"none" (the default), "left", "right", and "center". When you set the autoSize
property, true is a synonym for "left" and false is a synonym for "none".
The values of
autoSize and TextField.wordWrap determine whether a text field expands or
contracts to the left side, right side, or bottom side. The default value for each of these
properties is
false.
If
autoSize is set to "none" (the default) or false, then no resizing will occur.
If
autoSize is set to "left" or true, then the text is treated as left-justified text, meaning the
left side of the text field will remain fixed and any resizing of a single line text field will be on
the right side. If the text includes a line break (for example,
"\n" or "\r"), then the bottom
side will also be resized to fit the next line of text. If
wordWrap is also set to true, then only
the bottom side of the text field will be resized and the right side will remain fixed.
If
autoSize is set to "right", then the text is treated as right-justified text, meaning the right
side of the text field will remain fixed and any resizing of a single line text field will be on the
left side. If the text includes a line break (for example,
"\n" or "\r"), then the bottom side
will also be resized to fit the next line of text. If
wordWrap is also set to true, then only the
bottom side of the text field will be resized and the left side will remain fixed.