Annoying nulls

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:


**[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 :stuck_out_tongue: Hope it helps someone outthere…