Solved

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

Posted on 2008-10-13
5
1,381 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

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

695 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