A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: chop up hex 0xFFFFFF into three pieces

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    28

    chop up hex 0xFFFFFF into three pieces

    Hello,
    I can't seem to get this to work.
    I have a hex colorcode that I need to chop up into three parts.
    It's for a colormixer app.

    So I need to convert this :

    0xFFFFFF

    into this :

    FF FF FF


    Thanks for any help!!
    regards
    Lars J.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    This assumes your hex color code is a number and not a string (not from a text field).

    Code:
    rgb = 0xFFFFFF;
    
    r = (rgb >> 16);
    g = (rgb >> 8) & 0xFF;
    b = rgb & 0xFF;
    If you trace the value of r g and b, in this example, you should get 255 (which is the same as 0xFF).

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Posts
    28
    thanks very much JBUM!
    just what I needed (and will be needing)
    regards,
    Lars J.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center