TextInput setFocus在Flash Builder 4.6中不起作用

时间:2013-05-05 05:06:31

标签: actionscript-3 flex flex4 flash-builder flex4.5

我正在使用Flash Builder 4.6。并且正在为 flex项目工作,我希望在intitialize完成后在textInput上设置setFocus。我正在使用代码myTextInput.setFocus(); 这是工作正常光标闪烁但不突出显示TextInput以聚焦TextInput。我的所有代码都在这里:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init();">
    <fx:Script>
        <![CDATA[
            private function init():void{
                myTextInput.setFocus();
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Panel x="54" y="23" width="250" height="200">
        <s:TextInput x="98" y="42"/>
        <s:TextInput id="myTextInput" x="98" y="12"/>
    </s:Panel>
</s:Application>            

1 个答案:

答案 0 :(得分:0)

索引模板:

  

function setFocus(){
  window.document.getElementById("APPNAME").focus();
  $('#myTextInput').focus();
  $('#myTextInput').focusEnables=true;
} 
  </script>  </div>

应用:

private function init():void{
  if (ExternalInterface.available) {
      ExternalInterface.call('setFocus');
  } 
}