Is there a way to implement a disabled state on a (Spark) List ItemRenderer? I'm developing a List that has a counter on each of it's items. When a user drops that item, the counter decreases. When the item counter reaches 0 the item becomes disabled and the item image becomes black and white.
I have the disabled state in my custom item renderer but it doens't work. It's state should become "disabled" when I set the enabled property to false. I've tried to manually set the itemRenderer.currentState to "disabeld" and it becomes "normal" after I click on the list or if I resize the window.
This is how it should look like (notice that only the orange item is enabled and has colors because his counter still has 9 items):
I have no idea what's going in the background, can you please point me into the right direction?
Here's the SWF (source enabled )
All renderer visuals, including the state, must be derived from data or
interaction because of renderer recycling.
I would suggest you to go through the LifeCycle of a component. Those methods will help you manage this.
In your case you would need a property in you dataProvider that provides the quantity. This property should set a custom property of your component. The custom property should have a setter. Call invalidateProperties() and invalidateDisplayList() to do what you are trying to do in the setter.
You will have to override commitProperties() and updateDisplayList().