2012-02-09 115 views
0

我有皮肤下面我的按钮:不同的图标弯曲

<?xml version="1.0" encoding="utf-8"?><s:SparkSkin 
xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/halo" 
> 
<!-- host component --> 
<fx:Metadata> 
    <![CDATA[ 
    [HostComponent("spark.components.Button")] 
    ]]> 
</fx:Metadata> 

<!-- states --> 
<s:states> 
    <s:State name="up" /> 
    <s:State name="over" stateGroups="overStates"/> 
    <s:State name="down" stateGroups="overStates" /> 
    <s:State name="disabled" /> 
</s:states> 

..... 
</s:SparkSkin> 

我想知道我怎么可以有相同的皮肤不同的按钮添加不同的图像。

回答

1

两个步骤:

  1. 让你的自定义皮肤延长SparkButtonSkin而不是简单地 SparkSkin。
  2. 设置icon风格的按钮的

<s:Button icon="@Embed('/path/to/my-icon.png')" 
      skinClass="path.to.MyButtonSkin" /> 
+0

和第三个出现在这里:[http://stackoverflow.com/questions/2974518/flex4-if-i-want-different-icons-should-i-create-a-skin-class-for-each-button ](http://stackoverflow.com/questions/2974518/flex4-if-i-want-different-icons-should-i-create-a-skin-class-for-each-button) – sstauross 2012-02-10 10:10:52

+1

@sstauross由于Flex 4.5默认按钮有图标suppart内置。不再需要为此创建自定义类。 – RIAstar 2012-02-10 11:16:53

0

您可以设置(也就是你的完整路径或相对路径)的图像的路径

<s:Button label="Spark Button with dynamic icon" icon="assets/asterisk_orange.png" /> 

或嵌入图像

<s:Button label="Spark Button with inline embedded icon" icon="@Embed('assets/asterisk_orange.png')" />