我正在以编程方式填充文本字段并在添加新文本时滚动到 maxScrollH,以便用户可以看到文本的进度。这工作正常,直到我单击 TextField,它将 scrollH 设置回 0 并将插入符号放在文本中的等效位置。
textField.setSelection( text.length, text.length ); //sets the caretIndex/selection to the end
textField.scrollH = textField.maxScrollH; //scrolls to max
这是我在更新 textField 文本属性时用来滚动的代码。我尝试在 textField 上的 click 事件中添加一个侦听器,它以某种方式工作,但会导致可见的跳转。
override protected function createChildren() : void
{
super.createChildren();
textField.addEventListener(MouseEvent.CLICK, handleTextFieldClick, false, 0, true);
}
protected function handleTextFieldClick(event:MouseEvent):void
{
textField.scrollH = currentTextFieldScrollPosition; //stored scrollH value
trace(textField.scrollH);
}
我的猜测是有一个滚动位置正在计算或存储在我找不到的某个地方。