# Parents and problems

**URL:** <https://forum.kirupa.com/t/parents-and-problems/309936>\
**Category:** flash\
**Created:** [May 28, 2010, 3:01am UTC](https://forum.kirupa.com/t/parents-and-problems/309936 "2010-05-28T03:01:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacecadet](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@spacecadet](https://forum.kirupa.com/u/spacecadet)\
**Post date:** [May 28, 2010, 3:01am UTC](https://forum.kirupa.com/t/parents-and-problems/309936/1 "2010-05-28T03:01:32Z")

</div>

Hi, I’ve been trying to adapt to AS3 for a few days and am learning the new methods… I have a movieclip that i am loading in from the library using the addChild() code. When the movieclip has played through the timeline I wanted to put a removeMovieClip() command in the end so it self-removes once its completed.

I’ve had some success using the following code:

var par:MovieClip=MovieClip(parent);  
var par1:MovieClip=MovieClip(par.parent);  
par1.removeChild(par)

(the timeline is within a clip within the loaded movie)

and it seems to work, for a while and then after maybe the fourth time it will give me this error message:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at tunnel\_trial4\_fla::MC\_WallCrawler\_Grow\_15/frame140()

and then will work every other time.

The reason for the failure is that par1 is returning null.

Can anyone suggest why or at least where to look? I know some people have suggested this isn’t the way to handle parent/child things. But Im still learning and I can’t see why this wouldn’t work.

Ta

Matt.
