0

大家好,我有以下几点:

<s:ButtonBar id="tabs" y="15" left="0" height="31"
             change="VideosMenuBar_changeHandler(event)" requireSelection="true">  
    <s:layout>
        <s:HorizontalLayout gap="1" columnWidth="180" variableColumnWidth="false"   
                            />
    </s:layout>

    <s:ArrayCollection>
        <fx:String>Latest Videos</fx:String>
        <fx:String>Last Week Videos</fx:String>
        <fx:String>Last Month Videos</fx:String>
    </s:ArrayCollection>

</s:ButtonBar>

谁能告诉我如何在这个 (spark)ButtonBar 的每个按钮的左侧嵌入一个图标?我已经搜索了所有网络!

预先感谢!

4

1 回答 1

2

ButtonBar为(例如CustomButtonBarSkin)创建一个皮肤类

<s:ButtonBar id="tabs" y="15" left="0" height="31"
             skinClass="CustomButtonBarSkin"    
             change="VideosMenuBar_changeHandler(event)" requireSelection="true">  
    <s:layout>
        <s:HorizontalLayout gap="1" columnWidth="180" variableColumnWidth="false"   
                            />
    </s:layout>

    <s:ArrayCollection>
        <fx:String>Latest Videos</fx:String>
        <fx:String>Last Week Videos</fx:String>
        <fx:String>Last Month Videos</fx:String>
    </s:ArrayCollection>

</s:ButtonBar>

在皮肤类中查找按钮被定义为组件的部分,并将 's 的skinClass属性更改ButtonBarButton为自定义皮肤类(例如CustomButtonBarButtonSkin)。

<fx:Component id="firstButton">
    <!-- <s:ButtonBarButton skinClass="spark.skins.spark.ButtonBarFirstButtonSkin" /> -->
    <s:ButtonBarButton skinClass="CustomButtonBarButtonSkin" />
</fx:Component> 
[...]

自定义皮肤类ButtonBar基于spark.skins.spark.ButtonBarFirstButtonSkin或。spark.skins.spark.ButtonBarMiddleButtonSkinspark.skins.spark.ButtonBarLastButtonSkin

在自定义ButtonBarButton皮肤类中,您可以根据需要添加组件。在他离开的图像的情况下,课程看起来像这样。

<!-- layer 8: text -->
<!---  @copy spark.components.supportClasses.ButtonBase#labelDisplay -->
<s:Image source="@Embed('bricks.png')" />
<s:Label id="labelDisplay"
         textAlign="center"
         verticalAlign="middle"
         maxDisplayedLines="1"
         horizontalCenter="0" verticalCenter="1"
         left="10" right="10" top="2" bottom="2">
</s:Label>!

这就是它的外观

于 2012-02-09T08:07:33.523 回答