我遇到一个问题,即在我的应用程序中发生某些操作后,皮肤按钮会返回到默认皮肤。下面我已经包含了一个部分屏幕截图,您可以在其中观察问题。
单击左键后,左键将返回其默认外观(单击会触发状态转换)。右键是默认的蒙皮按钮。请注意,我的鼠标既没有翻过也没有按下左键。
Button Skin的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.Button")]
]]>
</fx:Metadata>
<fx:Script fb:purpose="styling">
<![CDATA[
import spark.components.Group;
static private const exclusions:Array = ["labelDisplay"];
override public function get colorizeExclusions():Array {return exclusions;}
override protected function initializationComplete():void
{
useChromeColor = true;
super.initializationComplete();
}
]]>
</fx:Script>
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<s:Rect id="fill" left="1" right="1" top="1" bottom="1" radiusX="2">
<s:fill>
<s:LinearGradient rotation="270">
<s:GradientEntry color.down="#545454"
color.over="#444444"
color="#343434"
alpha="0.95"/>
<s:GradientEntry color.down="#767676"
color.over="#666666"
color="#565656"
alpha="0.95"/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Rect id="border" left="0" right="0" top="0" bottom="0" width="69" height="20" radiusX="3">
<s:stroke>
<s:SolidColorStroke id="borderStroke" weight="1" color="#343434" caps="round" joints="round" />
</s:stroke>
</s:Rect>
<s:Label id="labelDisplay"
textAlign="center" verticalAlign="middle" maxDisplayedLines="1" fontSize="12"
left="10" right="10" verticalCenter="0"
color="#FFFFFF" fontFamily="SegoeUI">
</s:Label>
以下是导致问题的转换代码:
<s:Transition fromState="State0" toState="State1">
<s:Sequence targets="{[contacts_nocontacts, contacts_list, button_contacts, button_add, button_delete, ac_vgroup]}">
<s:Parallel>
<s:Fade target="{contacts_nocontacts}" alphaFrom="1" alphaTo="0" duration="200" />
<s:Fade target="{contacts_list}" alphaFrom="1" alphaTo="0" duration="200" />
<s:Fade target="{button_add}" alphaFrom="1" alphaTo="0" duration="200" />
<s:Fade target="{button_delete}" alphaFrom="1" alphaTo="0" duration="200" />
</s:Parallel>
<s:RemoveAction targets="{[contacts_nocontacts, contacts_list, button_add, button_delete]}" />
<s:AddAction targets="{[button_contacts, ac_vgroup]}" />
<s:Parallel>
<s:Fade target="{button_contacts}" alphaFrom="0" alphaTo="1" duration="300" />
<s:Fade target="{ac_vgroup}" alphaFrom="0" alphaTo="1" duration="300" />
</s:Parallel>
</s:Sequence>
</s:Transition>
答案 0 :(得分:1)
看起来皮肤被设置为spark.skins.spark.DefaultButtonSkin(不要与普通的Button皮肤混淆 - spark.skins.spark.ButtonSkin)。当您在Button上设置emphasized =“true”或该按钮被用作表单中的默认按钮时会发生这种情况。
有关如何自定义强调皮肤的示例,请参阅此主题:http://forums.adobe.com/message/3811868
答案 1 :(得分:0)
问题是,如果设置为Default button
的按钮失去焦点,则会重置皮肤。这是标准行为,可以在下面找到快速修复(这与Steven指出的解决方案相同,但在实际页面上更容易)
s|Button.emphasized {
skinClass: ClassReference("MyNewButtonSkin");
}
只需在按钮的emphasized
样式属性上附加相同的按钮skinClass即可。最快的方法是使用上面的CSS来做到这一点。通过这种方式,您可以立即定位所有按钮!