TextField 1223
Example
The following example creates two text fields that you can use to change the width and height
of a third text field on the Stage. Add the following ActionScript to a FLA or AS file.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 40, 160,
120);
my_txt.background = true;
my_txt.backgroundColor = 0xFF0000;
my_txt.border = true;
my_txt.multiline = true;
my_txt.type = "input";
my_txt.wordWrap = true;
this.createTextField("width_txt", this.getNextHighestDepth(), 10, 10, 30,
20);
width_txt.border = true;
width_txt.maxChars = 3;
width_txt.restrict = "0-9";
width_txt.type = "input";
width_txt.text = my_txt._width;
width_txt.onChanged = function() {
my_txt._width = this.text;
}
this.createTextField("height_txt", this.getNextHighestDepth(), 70, 10, 30,
20);
height_txt.border = true;
height_txt.maxChars = 3;
height_txt.restrict = "0-9";
height_txt.type = "input";
height_txt.text = my_txt._height;
height_txt.onChanged = function() {
my_txt._height = this.text;
}
When you test the example, try entering new values into
width_txt
and
height_txt
to
change the dimensions of
my_txt
.
The
MovieClip.getNextHighestDepth()
method used in this example requires Flash Player
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth()
method.
See also
_height (TextField._height property)
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...