2 Replies Latest reply on Aug 9, 2010 1:44 PM by Flex harUI

    Selectable <mx:Label> background color property

    pzzzza

      How can I change background color of selected text in my mx:Label when selectable=true.  Default color is blue.

      thanks in advance

        • 1. Re: Selectable <mx:Label> background color property
          ShardulSingh Level 3

          Hi,

           

          I think you should use something else for this use instead of Label.That will be better.

           

          But if you want to do this with Label only then the solution is as below.

          Create you own Label class which extends Label class of flex.And then use as I hv used it in my application.Below is the source

          code for both.

           

           

          CustomLabel.as

           

          package
          {
              import mx.controls.Label;
             
              public class CustomLabel extends Label
              {
                  public function CustomLabel()
                  {
                      super();
                  }
                 
                  public function getTxt() : *
                  {
                      return textField;
                  }
              }
          }


           

          MainApplication

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="vertical"
                  xmlns:local="*">
             
              <mx:Script>
                  <![CDATA[
                     
                      private function onCreationComplete():void
                      {
                          customLabel.getTxt().background = true;
                          customLabel.getTxt().backgroundColor = '0xFFFF00';
                      }
                     
                  ]]>
              </mx:Script>
             
              <local:CustomLabel id="customLabel" text="Hello world" selectable="true" creationComplete="onCreationComplete()"/>
             
          </mx:Application>

           

           

           

           

          Let me know if u hv any issue.

           

           

           

           

          with Regards,

          Shardul Singh Bartwal

          • 2. Re: Selectable <mx:Label> background color property
            Flex harUI Adobe Employee

            You can't change the selection color in mx:Label.