3 Replies Latest reply on May 13, 2010 11:08 PM by BhaskerChari

    how can i change <mx:Label></Label> using css?

    manpakhong

      Dear Experts,

       

      It is funny that <mx:Label> </mx:Label> doesn't have property to change the background color.

       

      Does anyone know how can i change <mx:Label></Label> using css?

       

      Regards,

       

      Man Pak Hong, Dave

       

      manpakhong@hotmail.com

        • 1. Re: how can i change <mx:Label></Label> using css?
          Flex harUI Adobe Employee

          A label with a background color would be heavier than one without.  Plenty

          of people have added such functionality to subclasses.  I think there are

          some blog posts if you search around.  Try FlexExamples first.

          • 2. Re: how can i change <mx:Label></Label> using css?
            manpakhong Level 1

            I find the answer myself.

             

            Flex 3 doesn't like the label background to be changed.
            But Flex 4/ Flash 4 Builder can. The official site of the controls.
            <mx:Label></mx:Label>
            doesn't show the property of it. However I find it my self.

             

            I test it by using the css.

             

            Label
            {
                 background-color: #0000FF;
            }

             

            I did it.

             

            Thanks.
            manpakhong@hotmail.com
            manpakhong
            Man Pak Hong, Dave

             

            Analyst Programmer

            • 3. Re: how can i change <mx:Label></Label> using css?
              BhaskerChari Level 4

              I think you have set the backgroundcolor for Label in Flex4...? In Flex3 doesn'y allow to set the background color directly...However you can use this work around if you want to set the background color.

               

              You can also set the color for textField in the code below by using the textField styleSheet property.

               

              <?xml version="1.0" encoding="utf-8"?>

              <mx:Application

               

              xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="applyBGtoLabel()">

               

              <mx:Script>

              <![CDATA[

               

              import mx.controls.Text;

               

               

              private function applyBGtoLabel():void

              {

               

              var textField:TextField = new TextField();

              textField = myLabel.mx_internal::getTextField();

              textField.background =

              true;

              textField.backgroundColor = 0xFF0000;

              }

               

              ]]>

               

              </mx:Script>

               

              <mx:Label

               

              id="myLabel" text="Apply a background color for me....please" height="25" />

               

              </mx:Application>

               

               

              Thanks ,

              Bhasker Chari.S