Reputation: 19463
How can I detect if there is any element in a container?
Example code:
<s:VGroup id="myGroup"></s:VGroup>
if(myGroup.getElementAt(0)){
//Got element inside
}else{
//Nothing inside
}
When I tried to run the above code, I get this error
RangeError: Index 0 is out of range.
How can I detect if there is any element loaded into the VGroup?
Thank you.
Upvotes: 0
Views: 39
Reputation: 39408
Use the numChildren property.
if(myGroup.numChildren > 0){
//Got element inside
}else{
//Nothing inside
}
Upvotes: 1