触发ButtonBar单击

时间:2012-03-08 21:20:06

标签: actionscript-3 flex flex-spark

我的皮肤很奇怪。我希望通过做一个涉及触发点击按钮按钮的按钮来修复它,但我不确定该怎么做。

这是我的按钮条形码

<s:ButtonBar id="tabs" dataProvider="{vs}"
             skinClass="skins.hatchedbuttonbarskins.TabBarSkin" 
             depth="100" width="80%" visible="true" 
             bottom="0" horizontalCenter="0" height="25" />
<mx:ViewStack id="vs" width="95%" height="625" 
              borderVisible="true" horizontalCenter="0">
    <s:NavigatorContent width="80%" height="100%" 
                        label="My Label" 
                        skinClass="skins.lg.TabNavigatorContent">
        <lists:ListCenter myLists="{this}" myButtons="{tabs}"/>
    </s:NavigatorContent>
...

此后还有三个navigatorcontent对象。

在ListCenter.mxml中,我想触发一下标签按钮栏按钮。这是我正在制作的动作脚本调用。

myButtons[1].dispatchEvent(new MouseEvent(MouseEvent.CLICK));

它给了我以下错误:

Error #1069: Property 1 not found on spark.components.ButtonBar and there is no default value.

如何访问按钮对象?

1 个答案:

答案 0 :(得分:0)

我不确定您要实现的目标,但您可以尝试更改ButtonBar.selectedIndex:

myButtons.selectedIndex = 1;

如果您真的想要访问按钮,请使用:

var btnBarBtn:ButtonBarButton = myButtons.dataGroup.getElementAt(0) as ButtonBarButton;

或者你可以描述你的皮肤问题,也许还有另一种解决方法。

相关问题