[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
I'm creating a 2D game and I was creating an event for when my character touches a gem, it 'collects' the gem and the image is removed. However when playing the game and the character touches the gem the game crashes and I am presented with the error.
This is the code that I added:
public function Collect():void
{
if (FireBoy.hitTestObject(Green))
{
Green.parent.removeChild(Green);
}
}
I have checked where the error is coming from and apparently the error lies with the line Green.parent.removeChild(Green);
What do I need to do to fix the error and to allow my character to still collect the gem?
