【发布时间】:2011-09-19 20:59:46
【问题描述】:
我在应该接受 5 位美国邮政编码的表单上有一个文本区域控件。我已经为控件分配了一个 keyUp 事件,该事件检查输入的字符数,直到达到 5,然后强制换行。
public function forceNewLine(event:KeyboardEvent):void
{
var maxLineChars:int = 5;
var currentLine:int = 1;
var numChars:int;
numChars = (txtList.text.length);
currentLine = Math.round(txtList.text.length / 6);
if (numChars == (maxLineChars * currentLine))
{
txtList.text = txtList.text + "\n";
txtList.setCursorPosition()
//This is not a function I have defined but I think I need too..
}
}
<s:TextArea id="txtList" keyUp="forceNewLine(event)"/>
除了插入新行时,光标移动到文本区域的开头之外,它工作正常。我希望它走到最后。
【问题讨论】:
标签: apache-flex actionscript-3 textarea mxml flash-builder