2 Replies Latest reply on Jan 4, 2010 1:34 PM by Dragos GEORGITA

    HTML Component set focus fails

    BridalLive Level 1

      I'm trying to set the focus on a text input after a page has been loaded inside an HTML component.  It does not appear to be working correctly. I can get a reference to the input field, but the focus() call fails.  Does anyone see what could be going on here?  I'm wondering if this is another bug with the HTML component.

       

      I've attached a complete AIR project to this post, but the main mxml file looks like this:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
         
          <mx:Script>
              <![CDATA[
                  private function onHTMLComplete(event:Event):void {
                      var dom:Object = event.target.domWindow.document;
                      var txtInput:Object = dom.getElementById("txtInput");
                      if(txtInput != null) {
                          txtInput.focus();
                      }
                     
                  }
              ]]>
          </mx:Script>
          <mx:HTML id="htmlComponent" width="100%" height="100%" location="app:/form.html" complete="onHTMLComplete(event)"/>
         
      </mx:WindowedApplication>

       

      And the form.html looks like this:

      <html>
          <body>
              <form>
                  <input type="text" id="txtInput" name="txtInput"/>
              </form>
          </body>
      </html>