drxav
asked on
test if a child exsists
Hi All,
I need to test to see if a child exists in a object... If it does I need to remove it, currently I am just trying to remove it and I am obviously getting a stack of runtime errors complaining that the child doesn't exist
Thanks
Xavier
I need to test to see if a child exists in a object... If it does I need to remove it, currently I am just trying to remove it and I am obviously getting a stack of runtime errors complaining that the child doesn't exist
Thanks
Xavier
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello,
Thanks for giving me an assist!
Just to be sure you're clear and to help you optimize. If the following line from your accepted solution returns a reference to an object:
var box2_mc = container_mc.getChildByNam e("Box2_mc ");
Then it's not necessary to use the 'contains()' method since the variable would be undefined if no child exists by that name.
Good luck and thanks again.
Thanks for giving me an assist!
Just to be sure you're clear and to help you optimize. If the following line from your accepted solution returns a reference to an object:
var box2_mc = container_mc.getChildByNam
Then it's not necessary to use the 'contains()' method since the variable would be undefined if no child exists by that name.
Good luck and thanks again.
ASKER
This is my code:
if (exclusionName != "DP_TL"){
removeChild(DP_TL);
}else{
activeDP = DP_TL;
}
needs to be something like:
if (exclusionName != "DP_TL" && childExists(DP_TL)){
removeChild(DP_TL);
}else{
activeDP = DP_TL;
}
I know that "childExists()" isnt a real function but thats to give you an idea as to what i mean.