Solved

test if a child exsists

Posted on 2008-06-15
5
3,576 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

705 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