2013-05-07 89 views
0

我創建了一個名爲HTMLBtnBlue.mxml的按鈕皮膚,我創建了一個帶有HTMLBtnBlue.mxml副本的另一個皮膚,並將其命名爲HTMLBtnYellow並將顏色更改爲0xF8C313。對於HTMLBtn.mxml 代碼如下Flex中的按鈕皮膚問題

<?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

我不明白:是''YellowSkin'的HTMLBtn'一個子類?這種黃色是如何應用的? – RIAstar 2013-05-07 19:55:29

回答

0

按照你上面的例子在Flash Builder 4.6與3.4 AIR:

<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> 

+0

我的問題已經解決,當我使用標籤屬性color.up =「#F8C313」,而不是使用styleName.up =「upStyle」 – eChampions 2013-05-09 18:16:04

+0

請發表您的答案作爲答案並將其標記爲已解決,以便其他人可以從您的解決方案中學習。 – 2013-05-09 23:21:12