Parent Movieclip/stage not found even if it is present

I'd like to ask this question which has been popping up on my mind often.

Why do i get this error saying parent does not exist when I try to remove a movieclip. In the first case, the movieclip cannot exist either on screen/memory if it was not 'contained' by either a movieclip or stage

How can this happen, can somebody explain how this "movieclip" loses its parent reference to the stage or container mc. The debugger stack shows the value of movieclip.parent as null.

Would be really helpful even if it were a small comment.

Thank you

Vishnu Ajit

happy coding


there is 2 possibility in this case. - either movieclip is not added to stage or any container. - or it's already removed from parent with some other mistake in code.

To prevent error when remove movieclip from parent. use this simple code to remove movieclip.

if(movieclip.parent) movieclip.parent.removeChild(movieclip);

it will prevent this error

MovieClips can very much exist even though they do not have a parent. Look at these rather standard lines of code:

var myThing:MovieClip = new ThingThatExtendsMovieClip();
// at this point in time myThing DOES exist yet does not have a parent

// now let's give it a parent

// and if we remove it again: 

// myThing again exists without a parent. 

The trick here is that if nothing is keeping a reference to myThing it will go away eventually. But as long as you do keep a reference to it, be it as a child or stored in a variable, it will stick around. Parent or not.

Need Your Help

Wamp Server : Path of uploaded files

path wamp

Hi I have a WAMP server where some files are upload into an specific path.

Scala vs Groovy vs Java for testing

java scala testing groovy integration-testing

If you need to choose the language to write your integration tests, what language would you pick? (from the above, or maybe another language).