Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

830 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