Take the following code from spark.skins.spark.ButtonSkin.mxml:
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
minWidth="21" minHeight="21"
alpha.disabled="0.5">
What does alpha.disabled
mean? Because alpha is a Number-type getter in class mx.core.UIComponent, and Numbers don't have a property called disabled
. Even if they did, I've never seen a property of a getter being set to something in an MXML element tag before, at least that I can remember.
I've tried to look in a couple of other spots to find what's going on there, but what does setting alpha.disabled
like this mean? What construct of the language is being used here? Thanks.
This is a reference to the "new" state syntax introduced in Flex 4.0. It means that when the state of the component is set to disabled the alpha property will be 0.5 . Otherwise the alpha state will be the default value--which I I assume 1.
When creating my own components; and using this approach, I like to specify values for every state. Sometimes I use the 'catch' all. Like this:
The above code means that in the disabled state the alpha property will be 0.5. In the normal state the alpha will be 1. In all other states the alpha will be 0.7.
The 'state' name after the property can also refer to a state group instead of an explicit state.