# Continued removeChild confusion

**URL:** <https://forum.kirupa.com/t/continued-removechild-confusion/332165>\
**Category:** flash\
**Created:** [February 19, 2014, 6:52pm UTC](https://forum.kirupa.com/t/continued-removechild-confusion/332165 "2014-02-19T18:52:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [February 19, 2014, 6:52pm UTC](https://forum.kirupa.com/t/continued-removechild-confusion/332165/1 "2014-02-19T18:52:22Z")

</div>

I am trying to remove a variable number (count) of display objects (MessageBubbles) from the display list. They are each referenced from an array called bArr:

```php
trace("bArr.length = " + bArr.length;
for (var g:int = 1; g <= count; g++) {
     var bbl:MessageBubble = bArr[bArr.length - 1] as MessageBubble;
     eArr.splice(eArr.length - 1, 1);
     if(bbl.parent != null) bbl.parent.removeChild(bbl);
}

```

But I’m getting “Error #1009: Cannot access a property or method of a null object reference.” on the last line in the loop. The trace indicates that bArr.length is nonzero.

I am forever confused about removeChild and null object references. What am I doing wrong here? And is there some “universal” formula for removing display objects? (I thought the line of code with the error WAS the universal way.)

Incidentally, each time a MessageBubble is created, it’s added to “blank” Sprite called container. I have no reason to believe that container should at any time not exist on the display list.
