У текстового поля (класс TextField) есть метод replaceSel, позволяющий заменить выделенный кусок текста заданной строкой:

Код AS1/AS2:
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 240);
my_txt.border = true;
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.type = "input";
my_txt.text = "Select some sample text from the text field and then right-click/control click "
+ "and select 'Enter current date' from the context menu to replace the "
+ "currently selected text with the current date.";
var my_cm:ContextMenu = new ContextMenu();
my_cm.customItems.push(new ContextMenuItem("Enter current date", enterDate));
function enterDate(obj:Object, menuItem:ContextMenuItem) {
var today_str:String = new Date().toString();
var date_str:String = today_str.split(" ", 3).join(" ");
my_txt.replaceSel(date_str);
}
my_txt.menu = my_cm;
Есть ли что-то подобное для компонента TextArea? (судя по всему, нет), и как можно создать что-то подобное (может, идея есть?).
Как ни пробовал - ничего не получается. Может, это как-то можно связать с расположением курсора? или лучше попробовать создать виртуальное поле, и обмениваться с ним данными для TextArea?