Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-13
5
Medium Priority
?
1,418 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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 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.
Suggested Courses

636 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