2012-03-08 102 views
0

我有一个奇怪的事情继续与我的皮肤。我希望通过做一个解决方法来解决这个问题,该方法涉及触发一个火花按钮栏按钮的点击,但我不确定如何做到这一点。触发ButtonBar点击

这里是我的按钮条形码

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

如何访问按钮对象?

回答

0

我不知道你想实现什么,而是你可以试着改变这样的ButtonBar.selectedIndex:

myButtons.selectedIndex = 1; 

如果你真的想访问按钮,然后使用:

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

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

+0

我在子组中设置图像以触发与按钮相同的事件。当你舔图像时,所选按钮的底部边界消失了。触发按钮绝对是一个黑客,但我是新来flex和使用别人的代码。不管怎样,谢谢! – liz 2012-03-08 23:43:03