TextField
1201
Example
The following example creates a text field that you can remove from the Stage when you click
the remove_btn instance. Create a button and call it
remove_btn
, and then add the following
ActionScript to your FLA or AS file.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 300,
22);
my_txt.text = new Date().toString();
my_txt.border = true;
remove_btn.onRelease = function() {
my_txt.removeTextField();
};
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.
replaceSel (TextField.replaceSel method)
public replaceSel(newText:String) : Void
Replaces the current selection with the contents of the
newText
parameter. The text is
inserted at the position of the current selection, using the current default character format and
default paragraph format. The text is not treated as HTML, even if the text field is an HTML
text field.
You can use the
replaceSel()
method to insert and delete text without disrupting the
character and paragraph formatting of the rest of the text.
You must use
Selection.setFocus()
to focus the field before issuing this command.
Availability:
ActionScript 1.0; Flash Player 6
Parameters
newText
:String
- A string.
Example
The following example code creates a multiline text field with text on the Stage. When you
select some text and then right-click or Control-click over the text field, you can select
Enter
current date
from the context menu. This selection calls a function that replaces the
selected text with the current date.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320,
240);
my_txt.border = true;
my_txt.wordWrap = true;
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...