Solved

test if a child exsists

Posted on 2008-06-15
5
3,563 Views
Last Modified: 2013-11-12
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
0
Comment
Question by:drxav
5 Comments
 
LVL 42

Assisted Solution

by:Rob Jurd, EE MVE
Rob Jurd, EE MVE earned 20 total points
ID: 21790215
for (part in myobject) {
    trace(part);
}
0
 
LVL 4

Author Comment

by:drxav
ID: 21790275
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.
0
 
LVL 3

Accepted Solution

by:
smash_pants earned 240 total points
ID: 21790293
0
 
LVL 4

Assisted Solution

by:emphaticDigital
emphaticDigital earned 240 total points
ID: 21828103
Hello,

You could use:

//pass name as a string, set the name using the 'name' property
if (exclusionName != "DP_TL" && getChildByName("DP_TL")){

Also you can check the suspected childs 'parent' variable, which should refrence 'this':

var isChild:Boolean = DP_TL.parent == this;//depends on scope
//or
var isChild:Boolean = DP_TL.parent == (variable referencing parent clip);//safer

both of these return 'true' if it's a child, then:
if (exclusionName != "DP_TL" && isChild){

I tested all of these and they work for me.

Good luck

0
 
LVL 4

Expert Comment

by:emphaticDigital
ID: 21866626
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP v5.4 and Class 'mysqli' not found  error 8 152
Web Modal Window 1 75
How to display HTML content in APEX 5.0? 5 103
Search on a site 5 92
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The goal of the tutorial is to teach the user how to how to record live broadcast.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now