Harish Sivaramakrishnan

Platform Evangelist @ Adobe

Color Picker Swatch Panel without the dropdown in Flex

leave a comment

Okay, the SwatchPanel.as class has always existed in Flex framework. But when I wanted to simply implement a swatch Panel, there was some bit dependency towards the ColorPicker (especially with the casting to ColorPicker in many places). I have a *very hacky* implementation of the SwatchPanel (using the SwatchPanel.as) here which I used in buiding the colrful desktop. I am feeling a little brave here to post the source code here. If any one has a better way of doing this one (I am sure there is, I haven’t gotten the time to ponder as of now :( ), please drop me a comment. (I could use that in my app)

Alternately, If any one wants to use my code to build something quick and dirty, grab the code from here.

Sample Usage:

var s:SwatchPanel = new SwatchPanel();
var wsp:WebSafePalette = new WebSafePalette();
var d:IList = wsp.getList();
s.dataProvider = d;

s.addEventListener(ColorPickerEvent.CHANGE, <Your Event Listener>);

Extract the zip file and maintain the same package structure and you can pretty much use what is in there as-is.

Written by Harish Sivaramakrishnan

February 16th, 2009 at 7:55 pm

Posted in Uncategorized

Leave a Reply