Solved

What is the correct way to check if a Movieclip exists, then remove it? AS3

Posted on 2008-10-13
5
1,378 Views
Last Modified: 2013-11-11
Hi there, how would i do this in AS3?

if(movieclip exists) {
remove that mc
}

thanks a lot any any help!
0
Comment
Question by:Jarmanje
[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
  • 2
  • 2
5 Comments
 
LVL 37

Expert Comment

by:CyanBlue
ID: 22704793
You could try this...

if (mcInstance)
{
   removeChild(mcInstance)
}

CyanBlue
0
 

Author Comment

by:Jarmanje
ID: 22705081
haha, go as dot org

This doesnt work for me, returns the below error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/removeChild()
      at index_fla::Centre_36/butc_click()

i want to remove the mc from the same stage that the button mc is placed

thanks for the reply
0
 
LVL 4

Expert Comment

by:MattKenefick
ID: 22715566
@CyanBlue Hey Jason!

@Jarmanje:

Where are you putting the code?

It looks like you're putting the code in something called "Centre_36" from a function called "butc_click". If you had your code on the timeline, your error would read something like: "at Untitled_fla::MainTimeline/Untitled_fla::frame1()"

If you want the code in the movieclip, use:

parent.removeChild( x );
0
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 22720687
Look who's here...  ;)

No update on here or AS.org, Jarmanje...  Did you solve the problem already???

CyanBlue
0
 

Author Comment

by:Jarmanje
ID: 22721879
hi there! I figured it out with your help. thanks a lot

if(loadmcC.stage) {
removeChild(loadmcC)
}
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

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…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

739 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