Color picker in flash:

Save the color spectrum image to local disk

Import into flash (ctrl+r) or File-import-import to stage..

select image and convert to symbol (ctrl+F8) or Modify--conver to symbol.. Name it as spectrum

Select the Movieclip in Stage and name it as img_mc in the property window

Draw rectangle using rectagle tool and convert to symbol, name it as rect

Select the Movieclip rect in Stage and name it as target_mc in the property window

Place the code below in the first frame..(right-click firstframe--select actions-paste the code in actions panel)

import flash.display.*;//Bitmap data class contained in display package
import flash.geom.*;//colorTransform contained in geom package
var image_bitmap = new BitmapData(img_mc._width, img_mc._height);//The BitmapData object to draw.
image_bitmap.draw(img_mc);//Draws a source image or movie clip onto a destination image
onMouseMove = function () {
if (img_mc.hitTest(_xmouse, _ymouse, true)) {//on moving mouse over movieclip
var curr_color:Number = image_bitmap.getPixel(img_mc._xmouse, img_mc._ymouse);//Returns an integer that reresents an RGB pixel value from a BitmapData object at a specific point (x, y).
var preview_colortansform = new ColorTransform();//The ColorTransform class lets you mathematically adjust all of the color values in a movie clip
preview_colortansform.rgb = curr_color;//The RGB color value for a ColorTransform object
target_mc.transform.colorTransform = preview_colortansform;
trace(curr_color.toString(16));//returning string value

The color picker for your project........!

Bookmark and Share


Michael said...

Very Good ! Thank you !

Levent said...

Thank you very much! This is exactly what I needed!

Saravanan said...

Yeah its my pleasure guys...

Thanks for your appreciations..

Fer said...

Doesnt work with AS3 T_T could u fix it plz?

Saravanan said...

Hi Fer,

I made it in Flash8 so it will not work in As3..

But soon you can expect next version in As3


Fer said...

kewwwl ty ^^


Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.