2 Replies Latest reply on Nov 2, 2010 11:19 AM by Whitetimer

    What do you datatype a color as ?

    Whitetimer Level 1

      Hi All


      Silly question, but if i create a var called BackgroundColor:<DATATYPE> = #000099 for example


      what datatype would i use ?


      many Thanks

        • 1. Re: What do you datatype a color as ?



          You would most definately store that as an unsigned integer (uint) in most contexts.

          In  ActionScript 1 and 2, I do believe there was a Color class, but in  ActionScript 3.0, the ColorTransform data type kinda took over, but I  don't think you want to use that for what seems to be a simpler purpose.


          So, for uint's, though:

          public const MY_BLUE:uint = 0x0354FF;

          obj.setStyle("color", MY_BLUE);


          If  you're familiar with hexadecimal, this answer should make sense to you,  otherwise, Wikipedia does a good job explaining that lovely number  system. Haha.


          Hope that helps!

          • 2. Re: What do you datatype a color as ?
            Whitetimer Level 1



            Thanks for the reply and advice.  The plan was to bind a components variable to the custom variable




            public var borderLabelBackgroundColor:uint = 0x000099;


            <s:BorderContainer id="BorderLabel" backgroundColor="{borderLabelBackgroundColor}" borderVisible="true" />


            Is this way ok or is there a better method ?


            Many thanks




            When i try this way, i get the following error


            [iuwth] Data binding will not be able to detect assignments to "borderLabelBackGroundColor"


            Any thoughts ?