我对 Flash 组件 ComboBox 有疑问。当我不想在 ComboBox 中保存名称时,它总是没有最后一个字母!?
这是代码:
var input_name:String;
text_field.addEventListener (TextEvent.TEXT_INPUT, text_input);
button.addEventListener (MouseEvent.CLICK, save);
function save (e:MouseEvent):void
{
text_field.visible = true;
text_field.adddEventListener(KeyboardEvent.KEY_DOWN, save_text);
}
function text_input(e:TextEvent):void
{
input_name = text_field.text;
}
function save_text(e:KeyboardEvent):void
{
var keyPressed:String = e.keyCode.toString();
if (keyPressed == "13")
{
combo.addItem({label:input_name, data:input_name});
}
}
因此,当我在文本字段中输入“foo”并按 ENTER 时,它会保存在组合框中,只是“fo”...
谢谢你的答案:)