我创建了一个名为HTMLBtnBlue.mxml的按钮皮肤,我创建了另一个带有HTMLBtnBlue.mxml副本的皮肤,并将其命名为HTMLBtnYellow,并将颜色更改为0xF8C313。 HTMLBtn.mxml的代码如下
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
.upStyle {
color: #FF0000;
}
.overStyle {
color: #009900;
}
.downStyle {
color: #00FF00;
}
.disabledStyle {
color: #666666;
}
</fx:Style>
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<s:Label
id="labelDisplay"
styleName.up="upStyle"
styleName.over="overStyle"
styleName.down="downStyle"
styleName.disabled="disabledStyle"/>
<s:Rect width="100%" height="1" includeIn="over,up" bottom="0">
<s:fill>
<s:SolidColor color.over="#009900" color.up="#0000FF"/>
</s:fill>
</s:Rect>
</s:Skin>
按钮代码如下
<s:Button label="Open Menu" id="bluebtn" skinClass="skins.HTMLBtn" />
<s:Button label="Close Menu" id="yellowbtn" skinClass="skins.YellowSkin" />
但它将HTMLBtn外观应用于“打开”菜单和“关闭菜单”按钮。
答案 0 :(得分:0)
按照上面的示例在Flash Builder 4.6中使用AIR 3.4:
<s:Button id="bluebtn" label="Open Menu" skinClass="skins.HTMLBtnBlue"/>
<s:Button id="yellowbtn" label="Close Menu" skinClass="skins.HTMLBtnYellow"/>
我没有遇到任何问题。
Skin Class "HTMLBtnYellow":
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
.upStyle {
color: #FF0000;
}
.overStyle {
color: #009900;
}
.downStyle {
color: #00FF00;
}
.disabledStyle {
color: #666666;
}
</fx:Style>
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<s:Rect width="100%" height="1" includeIn="over,up" bottom="0">
<s:fill>
<s:SolidColor color.over="#009900" color.up="#F8C313"/>
</s:fill>
</s:Rect>
<s:Label
id="labelDisplay"
styleName.up="upStyle"
styleName.over="overStyle"
styleName.down="downStyle"
styleName.disabled="disabledStyle"/>
皮肤类“HTMLBtnBlue”:
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
.upStyle {
color: #FF0000;
}
.overStyle {
color: #009900;
}
.downStyle {
color: #00FF00;
}
.disabledStyle {
color: #666666;
}
</fx:Style>
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<s:Label
id="labelDisplay"
styleName.up="upStyle"
styleName.over="overStyle"
styleName.down="downStyle"
styleName.disabled="disabledStyle"/>
<s:Rect width="100%" height="1" includeIn="over,up" bottom="0">
<s:fill>
<s:SolidColor color.over="#009900" color.up="#0000FF"/>
</s:fill>
</s:Rect>