I have a list control with ItemRenderer containing a Button. I need to change Button color for each instance within my ArrayCollection. How can I use the skin class to apply different colors for each button?
There are two solutions and I have provided the details below.
#1
In your ItemRenderer override the set data property and dynamically set the chromeColor based on the data, this also still gives you nice gradient normal, hover and click colors and effects.
override public function set data(value:Object):void
{
super.data = value;
btn.setStyle("chromeColor", data.color);
}
#2
SubClass Button and implement a backgroundColor style property create a new skin for you custom button based on the ButtonSkin and then draw the set backgroundColor from the hostComponent in the skin.
I just found an article from James Ward, so I will let credit for this part of the answer go to him :)
http://www.jamesward.com/2010/07/30/how-to-define-styles-on-skins-in-flex-4/
+