3

大家好,我有下面的代码来定义 Spark 中的按钮栏控件:

<s:ButtonBar id="tabs" y="15" left="0" height="31" change="VideosMenuBar_changeHandler(event)">  
        <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>

我有几个问题:

1)我怎样才能让这个按钮栏像 mx ToggleButtonBar 一样做出反应,即当我按下一个按钮两次不会失去其状态但保持它并且只有当我按下另一个按钮时才会改变?

2)如何定义默认按下的按钮?

3)最后,我在我的应用程序中应用了现成的 flex 皮肤,这为我的按钮提供了一些悬停、选择等属性,我如何通过按钮上的新皮肤定义我自己的?我可以定义新的吗?我的按钮栏的属性,以免受到皮肤中声明的所有者的影响,或者我是否必须更改该皮肤中的某些内容,如何做到这一点?

非常感谢您的帮助!

4

1 回答 1

4
  1. 确实。要求选择=“真”
  2. ButtonBar 扩展 List 所以设置 selectedIndex 属性应该可以工作
  3. 我不太确定您的意思,但是您可以使用 css 更改按钮栏中的按钮外观:

    s|ButtonBarButton { skin-class: ClassReference("my.skin.class"); }

或者,您可以通过创建自己的 ButtonBarSkin 来引用您的按钮来选择自定义按钮实现。

<fx:Declarations>
    <fx:Component id="firstButton">
        <you:MyLastButton />
    </fx:Component>

    <fx:Component id="middleButton" >
        <you:MyLastButton />
    </fx:Component>

    <fx:Component id="lastButton" >
        <you:MyLastButton />
    </fx:Component>
</fx:Declarations>

看看 Spark 自己的 ButtonBarSkin 作为一个很好的例子,并确保这些按钮至少实现 IItemRenderer 或者只是扩展 ButtonBarButton

于 2012-02-08T13:21:53.987 回答