5 Replies Latest reply on Oct 20, 2006 11:03 AM by cstormer

    Upcase in TextArea

    cstormer
      how to set first letter of the paragraph to be capital(upercase) letter in TextArea component?
        • 1. Re: Upcase in TextArea
          dimival Level 1
          You could call a function on the "change" event that changes the first character to UpperCase, an example:

          <mx:TextInput change="changeFirstLetter(event) "/>

          <mx:Script>
          <![CDATA[
          public function changeFirstLetter(event : Event) : void
          {
          event.currentTarget.text[0].toUpperCase();
          }
          ]]>
          </mx:Script>

          Hope this helps
          • 2. Re: Upcase in TextArea
            cstormer Level 1
            I'm getting an error

            ReferenceError: Error #1069: Property 0 not found on String and there is no default value.
            at test/changeFirstLetter()
            at test/___TextInput1_change()
            at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
            at flash.events::EventDispatcher/dispatchEvent()
            at mx.controls::TextInput/::textField_changeHandler()

            So I'm not sure that Your function working properly
            • 3. Re: Upcase in TextArea
              dimival Level 1
              Yep i realized i have a mistake, but now i have a solution:

              public function changeFirstLetter(event : Event) : void
              {
              var firstLetter:String = event.currentTarget.text.charAt(0).toUpperCase();
              event.currentTarget.text = firstLetter.concat(event.currentTarget.text.substr(1);
              }

              Try this one, and sorry for the previous one, i forgot that strings can't be accessed as arrays :P
              • 4. Re: Upcase in TextArea
                cstormer Level 1
                Thanx man thanx a lot
                • 5. Re: Upcase in TextArea
                  cstormer Level 1
                  I have sent You message to private so if You have any idea please conntact me.
                  Thanx once again