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

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


      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?




      Man Pak Hong, Dave



        • 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.
            doesn't show the property of it. However I find it my self.


            I test it by using the css.


                 background-color: #0000FF;


            I did it.


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



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





              import mx.controls.Text;



              private function applyBGtoLabel():void



              var textField:TextField = new TextField();

              textField = myLabel.mx_internal::getTextField();

              textField.background =


              textField.backgroundColor = 0xFF0000;









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





              Thanks ,

              Bhasker Chari.S