编辑
在您提出问题后,我迅速整理了一些东西来表明按钮可以是任何形状。如果您希望楼层是可选的,那么您可能想要 a ToggleButton
,而不是 aButton
所以我重新设计了我的示例,结果就是您所描述的
为什么不使用 Flex 4.0 蒙皮功能?您可以使用自己的外观/感觉获得按钮组件的行为(和状态):
<s:ToggleButton skinClass="FloorButton" y="0" />
<s:ToggleButton skinClass="FloorButton" y="25" />
<s:ToggleButton skinClass="FloorButton" y="50" />
您FloorButton
使用一些图像定义按钮皮肤 ( ):
<?xml version="1.0" encoding="utf-8"?>
<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"
alpha.disabledStates="0.5">
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.ToggleButton")]
]]>
</fx:Metadata>
<s:states>
<s:State name="up" />
<s:State name="over" stateGroups="overStates" />
<s:State name="down" stateGroups="downStates" />
<s:State name="disabled" stateGroups="disabledStates" />
<s:State name="upAndSelected" stateGroups="selectedStates, selectedUpStates" />
<s:State name="overAndSelected" stateGroups="overStates, selectedStates" />
<s:State name="downAndSelected" stateGroups="downStates, selectedStates" />
<s:State name="disabledAndSelected" stateGroups="selectedUpStates, disabledStates, selectedStates" />
</s:states>
<s:Path data="M 0 0 L 20 20 L 40 0 L 40 20 L 20 40 L 0 20">
<s:fill>
<s:SolidColor color="#AAAAAA" color.selectedStates="#000000" color.over="#777777" />
</s:fill>
</s:Path>
</s:SparkButtonSkin>
当然,可以将路径替换为具有透明度的PNG,以达到类似的效果。