要养成删除监听的好习惯,考虑在哪里删除
一定要考虑在哪里删除监听,不然后面的程序很可能会出错
funcMenuBut.addEventListener(FocusEvent.FOCUS_IN,SetInputBoxFocus);
funcMenuBut.addEventListener(FocusEvent.FOCUS_OUT,RemoveFuncMenuListener);
private function SetInputBoxFocus(event:FocusEvent):void //每次单击菜单项后,让inputBox重获焦点
{
trace("menu out");
inputBox.setFocus(); //每次单击后,焦点都要回到inputBox中
inputBox.selectRange(s_StaticPos,s_StaticPos); //焦点回到inputBox后的位置
trace(s_StaticPos);
}
private function RemoveFuncMenuListener(event:FocusEvent):void
{
funcMenuBut.removeEventListener(FocusEvent.FOCUS_IN,SetInputBoxFocus);
}