【问题标题】:Flex detect element in containerFlex 检测容器中的元素
【发布时间】:2014-01-02 21:38:29
【问题描述】:

如何检测容器中是否有任何元素?

示例代码:

<s:VGroup id="myGroup"></s:VGroup>

if(myGroup.getElementAt(0)){
    //Got element inside
}else{
    //Nothing inside
}

当我尝试运行上面的代码时,我得到了这个错误

RangeError: Index 0 is out of range.

如何检测是否有任何元素加载到 VGroup 中?

谢谢。

【问题讨论】:

  • 虽然答案很简单 [我已发布] 我不确定我是否理解需要这样做的理由。为什么你的“父母”需要反省孩子?

标签: flash apache-flex


【解决方案1】:

使用numChildren 属性。

if(myGroup.numChildren > 0){
    //Got element inside
}else{
    //Nothing inside
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-20
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    • 2020-09-19
    • 2021-03-18
    • 2023-04-08
    • 2019-08-18
    相关资源
    最近更新 更多