3 Replies Latest reply on Dec 14, 2007 12:23 PM by jkj14

    Set focus to textfield

      Hi guyz I knew this is a simple problem.Im just a beginner someone please help me.
      Im creating the text field at runtime.By default i just want to set the focus to the textfield

        • 1. Re: Set focus to textfield
          rvollmar Level 1
          Try using setFocus(). Here's an example.
          - Rob

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="doCreationComplete()" >
          import mx.controls.TextArea;

          private function doCreationComplete():void{
          var ta2:TextArea = new TextArea();
          ta2.text = "I should have focus.";

          <mx:HBox id="hbx1">
          <mx:Label text="ta1:" />
          <mx:TextArea id="ta1" />

          <mx:HBox id="hbx2">
          <mx:Label text="ta2:" />
          • 2. Re: Set focus to textfield
            ntsiii Level 3
            Be aware that when you first load a Flex app, the Flash Player itself does not have the focus. Therefore, your control will have the focus within the app, but you will not be able to start typing directly.

            Tthe usual fixfor this is to have a piece of javascript in the html wrapper that sets the focus to the Flash Player.

            • 3. Re: Set focus to textfield

              how exactly can this be done using the index.template.html in flex builder 2 project?(a working sample would be nice)