Formatting text objects in Flash using ActionScript
Using ActionScript you can set, change, and format dynamic text fields and input text fields. For example, here is a text field I was just formatting to display the Flash Player version.
// Create textfield
_root.createTextField("playerVersion", 1, 0, 0, 200, 150);
// Query the user’s version of Flash
playerVersion.text = System.capabilities.version;
// Create a TextFormat object
var txtfmt:TextFormat = new TextFormat();
// Specify paragraph and character formatting
txtfmt.bold = true;
txtfmt.font = "Verdana";
txtfmt.size = 18;
// Apply the TextFormat object to the text field
playerVersion.setTextFormat(txtfmt);
There’s a neat tutorial available at Dev Articles. Macromedia also has useful information on the text format class.
Another useful resource, if you haven't created text objects in ActionScript before, is Macromedia's dictionary example of MovieClip.createTextField.
myMovieClip .createTextField ( instanceName , depth , x , y , width , height )
// Create textfield
_root.createTextField("playerVersion", 1, 0, 0, 200, 150);
// Query the user’s version of Flash
playerVersion.text = System.capabilities.version;
// Create a TextFormat object
var txtfmt:TextFormat = new TextFormat();
// Specify paragraph and character formatting
txtfmt.bold = true;
txtfmt.font = "Verdana";
txtfmt.size = 18;
// Apply the TextFormat object to the text field
playerVersion.setTextFormat(txtfmt);
There’s a neat tutorial available at Dev Articles. Macromedia also has useful information on the text format class.
Another useful resource, if you haven't created text objects in ActionScript before, is Macromedia's dictionary example of MovieClip.createTextField.
myMovieClip .createTextField ( instanceName , depth , x , y , width , height )
0 Comments:
Posta un commento
<< Home