Search code examples
actionscript-3movieclipcolor-picker

Get Color of movie clip clicked ActionScript 3.0


I want the hexColor of the movieclip which is clicked. My movieclip is a red circle with solid color. So on click of the red circle, it should return me 0xff0000. I use the following but I do not get the desired result. It only returns me 0.

trace(redcircle.transform.colorTransform.color.toString(16));

Solution

  • You can also use a BitmapData.getPixel() to get the color of your MovieClip :

    var bmpd:BitmapData = new BitmapData(mc.width, mc.height);
        bmpd.draw(mc);
    
    // supposed that your circle is at (0, 0)
    var color:uint = bmpd.getPixel(mc.width/2, mc.height/2);
    
    trace(color.toString(16));  // gives : ff0000
    

    Hope that can help.