Link to home
Start Free TrialLog in
Avatar of drxav
drxavFlag for Australia

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
SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of drxav

ASKER

thats not what i need.

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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of emphaticDigital
emphaticDigital

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.getChildByName("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.