How do I convert RGB numeric value to Hex in Actionscript 3?

Posted on 2009-04-23
Last Modified: 2013-11-11
Greetings Experts!

Can you please assist me with converting an RGB value to Hex?

For instance, I'm using getPixel(mc.mouseX, mc.mouseY) to return an RGB value - such as 16651277.  I would like to convert this number to hex.

What's the simplest method for handling this? Can I do a direct conversion of this RGB value to hex without breaking it down into its R, G, and B components?

Question by:bham3dman
    LVL 37

    Accepted Solution

    You could use toString() function to do so...

    var dec:Number = 16651277;
    var hex:String = dec.toString(16);
    trace(hex);  // fe140d

    Open in new window

    LVL 5

    Author Comment

    Ah...thanks for the help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Stock Videos 17 315
    Adobe Presenter not Publishing Slide Theme 17 108
    Online Course Not Responding 3 80
    Adobe Flash Player ActionScript error 6 47
    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now