我可以通过索引值禁用 Spark 按钮栏按钮,还是必须通过按钮皮肤来执行此操作,如图 here使用标签。
以及我想做的事情的示例:
public function disableButton(index:uint):void
{
var button:ButtonBarButton = this.getChildAt(index) as ButtonBarButton;
button.enabled = false;
}
这不起作用,因为按钮对象返回 null。
最佳答案
您想要的代码是:
public function disableButton(index:int):void
{
// Bounds check
if (index < 0 || index >= this.dataGroup.numElements) return;
var btn:ButtonBarButton = this.dataGroup.getElementAt(index) as ButtonBarButton;
if (btn)
{
btn.enabled = false;
}
}
这是一个complete working example .
关于flash - 按索引禁用 Spark 按钮栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11318870/