Показать сообщение отдельно
Старый 25.09.2006, 00:58
afarber вне форума Посмотреть профиль Отправить личное сообщение для afarber Посетить домашнюю страницу afarber Найти все сообщения от afarber
  № 4  
Ответить с цитированием
afarber
 
Аватар для afarber

Регистрация: May 2006
Адрес: Germany
Сообщений: 74
Я вот и так попробовал - с area_txt.onMouseWheel = Delegate(...),
но все равно не горит волшебный фонарь, не крутит колесико

Код:
import mx.utils.Delegate;

class Chat extends MovieClip {
	private var field_txt:TextField;
	private var area_txt:TextField;
	private var up_btn:Button;
	private var down_btn:Button;
			
	public function Chat() {
		field_txt.maxChars = 1024;
		area_txt.mouseWheelEnabled = false;

		Key.addListener(this);
		//Mouse.addListener(this);

		up_btn.onRelease = Delegate.create(this, scrollUp);
		down_btn.onRelease = Delegate.create(this, scrollDown);
		area_txt.onMouseWheel = Delegate.create(this, scrollLines);
		
		updateButtons();
	}

	public function onKeyDown() {
		if (Key.getCode() == Key.ENTER &&
		    field_txt.text != '' &&
		    Selection.getFocus() == targetPath(field_txt)) {
			setText(getText());
			Selection.setFocus(field_txt);
	  	}
	}
	
	public function scrollUp() {
		area_txt.scroll--;
		updateButtons();
	}
	
	public function scrollDown() {
		area_txt.scroll++;
		updateButtons();
	}

	public function scrollLines(lines:Number) {
		area_txt.scroll -= lines;
		updateButtons();
	}
	
	public function getText():String {
		var str:String = field_txt.text;
      		field_txt.text = '';
		return str;
	}
	
	public function setText(str:String) {
		area_txt.scroll = area_txt.maxscroll;
		area_txt.text += newline + str;
		updateButtons();
	}
	
	private function updateButtons():Void {
		up_btn._visible   = (area_txt.scroll > 1 ? true : false);
		down_btn._visible = (area_txt.scroll < area_txt.maxscroll ? true : false);
	}
}