Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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 how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now