Replacesel (Textfield.replacesel Method) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

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
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()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the

replaceSel (TextField.replaceSel method)

public replaceSel(newText:String) : Void
Replaces the current selection with the contents of the
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()
character and paragraph formatting of the rest of the text.
You must use
Selection.setFocus()
Availability: ActionScript 1.0; Flash Player 6
Parameters
- A string.
newText: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
from the context menu. This selection calls a function that replaces the
current date
selected text with the current date.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320,
240);
my_txt.border = true;
my_txt.wordWrap = true;
remove_btn
method used in this example requires Flash Player
MovieClip.getNextHighestDepth()
method to insert and delete text without disrupting the
to focus the field before issuing this command.
, and then add the following
method.
parameter. The text is
newText
Enter
TextField
1201

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF