?
Solved

test if a child exsists

Posted on 2008-06-15
5
Medium Priority
?
3,584 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 43

Assisted Solution

by:Rob
Rob earned 60 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 720 total points
ID: 21790293
0
 
LVL 4

Assisted Solution

by:emphaticDigital
emphaticDigital earned 720 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

649 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