flash - 按索引禁用 Spark 按钮栏按钮

标签 flash apache-flex actionscript

我可以通过索引值禁用 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/

相关文章:

apache-flex - 在 flex 中显示麦克风事件

apache-flex - 用于 flex/actionscript 的逆向工程或文档工具

python - 使用 ByteArrays 解压缩 Zlib 字符串

actionscript-3 - Flex 数字微调器,要添加前面的 0

apache-flex - ActionScript 中组件不同部分的不同工具提示

iphone - Shadowbox YouTube 视频未出现在 iphone 设备上

iphone - 闪存 iOS 应用程序

flash - actionscript3参数错误: Error #2015: Invalid BitmapData

actionscript-3 - 支持flash游戏中的多种分辨率

javascript - 从 flash 调用 jQuery 函数