【发布时间】:2011-12-29 01:57:38
【问题描述】:
我尝试为 Spark 按钮构建 Flex 4 皮肤,这是典型的做法。我根据自己的喜好调整了颜色和其他样式,包括在不同状态下使用点选择器指定替代颜色等。但是,当按钮被禁用时,这些都会被忽略。不管我做什么,在禁用状态下,我的按钮总是有错误的颜色并且是 alpha'd 到 0.5(即使我特别声明 alpha.disabled="1")。所有其他皮肤状态都按预期工作。这是怎么回事?
这是我的自定义皮肤。如果它工作正常,它看起来没有阴影或高光,并且是渐变灰色。相反,它显示为 up 状态的 50% alpha 版本(闪亮的绿色)。
<?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"
minWidth="21" minHeight="21" alpha.disabled="1">
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.Button")]
]]>
</fx:Metadata>
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<s:Rect id="backgroundAndShadow" left="0" right="0" top="0" bottom="0" radiusX="5" radiusY="5">
<s:filters>
<s:DropShadowFilter blurX="5" blurY="5" blurX.down="3" blurY.down="3" alpha="0.5" distance="1" distance.down="0" angle="90" excludeFrom="disabled" />
</s:filters>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color.up="#00AD00" color="#007A00" color.disabled="#cccccc" />
<s:GradientEntry color.up="#29FF29" color="#00F500" color.disabled="#bbbbbb" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Rect id="highlight" left="1" right="1" top="1" height="50%" topLeftRadiusX="4" topLeftRadiusY="4" topRightRadiusX="4" topRightRadiusY="4" excludeFrom="disabled">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="#ffffff" alpha="0.8" />
<s:GradientEntry color="#ffffff" alpha="0.3" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Label id="labelDisplay"
textAlign="center"
horizontalCenter="0" verticalCenter="1" verticalAlign="middle"
color="#ffffff" color.disabled="#555555"
fontWeight="bold"
left="2" right="2" top="2" bottom="2">
<s:filters>
<s:DropShadowFilter blurX="3" blurY="3" alpha="0.5" distance="1" distance.down="0" angle="90" excludeFrom="disabled" />
</s:filters>
</s:Label>
</s:SparkButtonSkin>
我还使用 Flash Builder 的皮肤创建向导/对话框为 Button 自动生成了皮肤。即使这样,在禁用模式下专门将 alpha 设置为 1 也没有效果。
编辑
这是用于创建然后禁用按钮的代码:
_action1Button = new Action1Button();
view.actionGroup.addElement(_action1Button);
_action1Button.enabled = false;
错误在于 _action1Button 不是实际的按钮,而是按钮的容器。嗬!将其切换到 _action1Button.actionButton.enabled = false; 解决了这个问题。
【问题讨论】:
标签: apache-flex skinning flex-spark