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

Hi there, how would i do this in AS3?

if(movieclip exists) {
remove that mc

thanks a lot any any help!
Who is Participating?
CyanBlueConnect With a Mentor Commented:
Look who's here...  ;)

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

You could try this...

if (mcInstance)

JarmanjeAuthor Commented:
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
@CyanBlue Hey Jason!


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 );
JarmanjeAuthor Commented:
hi there! I figured it out with your help. thanks a lot

if(loadmcC.stage) {
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.