Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Working with Text and Strings > About text fields > About manipulating text fields > Changing a text field's position | |||
You can change a text field's position on the Stage at runtime. You need to set new values for the text field's _x and _y properties, as shown in the following example.
To reposition a text field by using ActionScript:
this.createTextField("my_txt", 10, 0, 0, 300, 200);
my_txt.border = true;
my_txt.text = "Hello world";
my_txt._x = (Stage.width - my_txt._width) / 2;
my_txt._y = (Stage.height - my_txt._height) / 2;
For samples that demonstrate how to work with text fields using ActionScript, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download the Samples zip file and navigate to the ActionScript 2.0/TextFields folder to access these samples:
|
|
|
|