3 Replies Latest reply on May 10, 2011 6:15 AM by digsafe

    Getting the TextInput data

    digsafe

      This seems like it should be a no-brainer, but I can't find any examples and have been unsuccessful in my attempts.

      I want to capture the input text as a string and display it in a text box.

       

      <?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"  >


          <fx:Script>
              <![CDATA[


                  private function tester1():void{
                      myTextArea.text += "\r: "+clientName;
                     
                  }
              ]]>
          </fx:Script>
          <s:layout>
              <s:VerticalLayout/>
          </s:layout>
      <s:VGroup>     
              <s:TextArea id="myTextArea"  width="300" height="100" />
              <s:Button label="TEST" click="tester1();" />   
          <mx:FormItem label="Client Name" >
              <s:TextInput id="clientName"/>
          </mx:FormItem>
             
          </s:VGroup > 
         
      </s:Application>

        • 1. Re: Getting the TextInput data
          miguel8312 Level 3

          i believe you are looking for the change event of the text area have you given that a try yet?

          Miguel

          • 2. Re: Getting the TextInput data
            digsafe Level 1

            So you are saying I need to assign it an event listener?

            Would I assign it to the TextInput of the FormItem?

            • 3. Re: Getting the TextInput data
              digsafe Level 1

              Ugh. So simple.

              Just needed to access the  ".text" property of the TextInput

              derp.

               

               

              <?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"  >


                  <fx:Script>
                      <![CDATA[


                          private function tester1():void{
                              myTextArea.text += "\r: "+clientName.text;
                             
                          }
                      ]]>
                  </fx:Script>
                  <s:layout>
                      <s:VerticalLayout/>
                  </s:layout>
              <s:VGroup>     
                      <s:TextArea id="myTextArea"  width="300" height="100" />
                      <s:Button label="TEST" click="tester1();" />   
                  <mx:FormItem label="Client Name" >
                      <s:TextInput id="clientName"/>
                  </mx:FormItem>
                     
                  </s:VGroup > 
                 
              </s:Application>