Hey,
Ive been working on a new project recently and ive run into an old favourite error of mine and cant seem to get my head around it.
I have added objects to the stage and call a function later to delete them, when i call the removeChild() function i get an error saying that there is no parent to my child which there is, i have this debug going and still get this
“Couldn’t remove object. Parent property is null.”
This is the removeing function here
public static function removeEntity(obj:Object):void
{
if (obj)
{
if (obj is DisplayObject)
{
if (obj.parent)
{
try
{
obj.parent.removeChild(obj);
} catch (e:Error)
{
trace("Couldn't remove the object. It wasn't a child of a DisplayObject.");
}
}else
{
trace("Couldn't remove object. Parent property is null.");
}
} else
{
trace("Couldn't remove object. It is not a DisplayObject.");
}
} else
{
trace("Couldn't remove the object. It was null or doesn't exist.");
}
}
Anyone have any ideas as to fixing this error?