# Annoying nulls

**URL:** <https://forum.kirupa.com/t/annoying-nulls/315997>\
**Category:** Uncategorized\
**Created:** [November 9, 2010, 6:11pm UTC](https://forum.kirupa.com/t/annoying-nulls/315997 "2010-11-09T18:11:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [November 9, 2010, 6:11pm UTC](https://forum.kirupa.com/t/annoying-nulls/315997/1 "2010-11-09T18:11:58Z")

</div>

I’m working on large project and keep getting errors:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  
TypeError: Error #2007: Parameter child must be non-null.

It can be quite frustrating (:

I’ve added two simple overrides to my base classes:

```auto

**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]public [/COLOR][/SIZE][/COLOR][/SIZE]****[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]override [/COLOR][/SIZE][/COLOR][/SIZE]****[SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] addChild(child:DisplayObject):DisplayObject {[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff] if[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] (child != [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]null[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]) [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]super[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2].addChild(child);[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff] return[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] child;[/SIZE]
[SIZE=2]}[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]public [/COLOR][/SIZE][/COLOR][/SIZE]****[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]override [/COLOR][/SIZE][/COLOR][/SIZE]****[SIZE=2][COLOR=#339966][SIZE=2][COLOR=#339966]function[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] removeChild(child:DisplayObject):DisplayObject {[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff] if[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] (child.parent != [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]null[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2]) [/SIZE]**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]super[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2].removeChild(child);[/SIZE]
**[SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff] return[/COLOR][/SIZE][/COLOR][/SIZE]**[SIZE=2] child;[/SIZE]
[SIZE=2]}[/SIZE]

```

…saved me a lot of time and nerves 😛 Hope it helps someone outthere…
