google.com, pub-6980195464912582, DIRECT, f08c47fec0942fa0

ЗДЕСЬ МОЖЕТ БЫТЬ ВАША РЕКЛАМА!

БАННЕР 500 х 90 тИЦ=10 PR=3
Просмотров более 5000 в месяц.
Цена 2000 рублей в месяц.
Деньги от рекламы идут на ВАШ инвестиционный счет в проекте СПИ
КРАУДФАНДИНГ!
Исполняем желания!
ВЛОЖИСЬ В БУДУЩЕЕ!

МАШИНОСТРОЕНИЕ И МЕТАЛЛООБРАБОТКА. САПР. CAD\CAM\CAE\PLM. ФОРУМ ИНЖЕНЕРОВ!

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » МАШИНОСТРОЕНИЕ И МЕТАЛЛООБРАБОТКА. САПР. CAD\CAM\CAE\PLM. ФОРУМ ИНЖЕНЕРОВ! » JavaScript, VBScript, Flash & ActionScript, AJAX » Обработка выделенного текста в текстовом поле средствами AS


Обработка выделенного текста в текстовом поле средствами AS

Сообщений 1 страница 3 из 3

1

Flash CS3 Documentation

ActionScript 2.0 Language Reference > ActionScript classes > TextField > replaceSel (TextField.replaceSel 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.

Note: This method will not work if a style sheet is applied to the text field.

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;
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;

0

2

Может еще кто что предложит?

0

3

Что то не совсем ту ссылку мне дали на форуме программистов.
Вот нашел нужные мне функции:
nSelBegin=Selection.getBeginIndex(inp); //номер первого выделенного символа
nSelEnd=Selection.getEndIndex(inp); //номер последнего выделенного символа
nSelCaret=Selection.getCaretIndex(inp); // узнаем позицию курсора

Но что то у меня не выходит! все ф-ции возсращают значение -1. В чем дело?
Может кто знает?

0


Вы здесь » МАШИНОСТРОЕНИЕ И МЕТАЛЛООБРАБОТКА. САПР. CAD\CAM\CAE\PLM. ФОРУМ ИНЖЕНЕРОВ! » JavaScript, VBScript, Flash & ActionScript, AJAX » Обработка выделенного текста в текстовом поле средствами AS