4 Replies Latest reply on Aug 12, 2010 12:47 AM by Francisc

    Style Font in Spark TextInput Control

    Francisc Level 3

      Hello!

       

      How can I do as the title indicates please?

      Can I do it without using a custom skin because I want to be able to change fontColor and fontStyle programatically.

       

      Thanks!

        • 1. Re: Style Font in Spark TextInput Control
          ShardulSingh Level 3

          You can acheive it very easily with spark textinput too. Pls check below and let me know if you have any issue.

           

           

          <?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">
              <fx:Declarations>
                  <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
              <fx:Script>
                  <![CDATA[
                      import mx.collections.ArrayCollection;
                     
                      [Bindable]
                      private var acFontSizes : ArrayCollection = new ArrayCollection([
                          {fontSize : '12'},
                          {fontSize : '16'},
                          {fontSize : '20'},
                          {fontSize : '24'},
                          {fontSize : '28'},
                          {fontSize : '32'},
                          {fontSize : '36'},
                          {fontSize : '40'},
                          {fontSize : '44'}
                      ]);
                  ]]>
              </fx:Script>
              <mx:VBox>
                      <s:TextInput id="txtInput" width="150" height="50" text="Your Text" fontSize="{comboFontSize.selectedItem.fontSize}" color="{colorCombo.selectedColor}"/>
                      <mx:HBox>
                          <s:Label text="Choose Color"/>
                          <mx:ColorPicker id="colorCombo"/>
                      </mx:HBox>
                      <mx:HBox>
                          <s:Label text="Choose Font Size"/>
                          <s:ComboBox id="comboFontSize" dataProvider="{acFontSizes}" labelField="fontSize" selectedIndex="0"/>
                      </mx:HBox>
              </mx:VBox>
          </s:Application>

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

          with Regards,

           

          Shardul singh Bartwal

          • 2. Re: Style Font in Spark TextInput Control
            Francisc Level 3

            Hello. I already tried that and it doesn't work.

             

            I mean setting fontSize and color on the Spark TextInput control.

            • 3. Re: Style Font in Spark TextInput Control
              Francisc Level 3

              Hello.

               

              You example works, however in my project, setting: <s:TextInput color="#CCCCCC"/> does not.

              Very strange.

              • 4. Re: Style Font in Spark TextInput Control
                Francisc Level 3

                Got it.

                 

                It was because I had * CSS Selector set to color:#000000;

                 

                I still think it's a bug though. That should affect only properties that are not specified.