2 Replies Latest reply on Oct 29, 2006 11:42 AM by leotemp

    Handling RGB values from controls

    leotemp Level 1
      How can i convert the colors values returned from a colorPickers.selectedColor property to an RGB value that is web friendly.
      Example:
      red ff0000 = 16711680 when taken from the colorPicker
      blue 0000ff = 255 when taken from the colorPicker

      Why is this and how can i overcome this issue?
        • 1. Handling RGB values from controls
          leotemp Level 1
          Ok, when i do this, colorPickerId.selectedColor.toString(16); I at least get something that looks like hex but allot of the times its only 2 or 3 digits so it wont work for my purposes. I am try to dynamically write to a css file from a flex app and then use that same css in another flex app. When i take color values from a colorPicker control it gives me large numbers and the closest thing i have found to converting that to a usable color value is the above snippet. What am doing wrong here?

          • 2. Re: Handling RGB values from controls
            leotemp Level 1
            Just adding zeros to the front of my number fixed my problem:

            Javascript Example:
            function checkHex(str) {
            if (str.length<6) {
            do
            {
            str="0"+ str;
            }
            while (str.length != 6)
            }
            return str
            }