Просмотр полной версии : Переброс текста по нажатию клавиши.
valter512
27.11.2006, 01:31
На сцене есть Textarea, есть InputText. Как по нажатию клавиши "ентер" перевести текст из InputText в TextArea?
Проблема тут в обработке события нажатия клавиши "ентер".
Помогите.
import flash.events.KeyboardEvent;
import flash.events.FocusEvent;
import flash.ui.Keyboard;
private function initApp():void {
this.textInput.addEventListener(FocusEvent.FOCUS_IN,this.focusHandler);
this.textInput.addEventListener(FocusEvent.FOCUS_OUT,this.blurHandler);
}
private function focusHandler(event:FocusEvent):void {
this.addEventListener(KeyboardEvent.KEY_DOWN,this.keyHandler);
}
private function blurHandler(event:FocusEvent):void {
this.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyHandler);
}
private function keyHandler(event:KeyboardEvent):void {
if (event.keyCode==Keyboard.ENTER) {
this.textArea.text += this.textInput.text+'\n';
this.textInput.text = '';
}
}
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.