Skip to main content
klinek3
Inspiring
January 28, 2011
Answered

Target movieclip from an AS3 class file - remove/add Child

  • January 28, 2011
  • 2 replies
  • 2097 views

Halo.

I have a very simple question  (for those who use external class files).

Assuming that I have a MovieClip manually added to Stage and I want to access it from inside my class definiton.

So the code would be:

MovieClip(root).MyMovieClip

But I can't figure out how to use remove/add Child in that kind of situation.

I will appreciate any advice.

Thanks

This topic has been closed for replies.
Correct answer kglad

if you can reference using that, you can remove using:

MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);

and you can add to any displayobjectcontainer.

2 replies

michaeltowse-D9Wc11
Inspiring
March 2, 2011

Just that line

MovieClip(root).MyMovieClip

Helped me out, thanks

Mike

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 28, 2011

if you can reference using that, you can remove using:

MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);

and you can add to any displayobjectcontainer.

klinek3
klinek3Author
Inspiring
January 28, 2011

Ok.

Works fine.

Regards for 'kglad'

kglad
Community Expert
Community Expert
January 28, 2011

you're welcome.