0
        private var _hud:HUDc = new HUDc();

        private function someMethod():void
        {
            if(stage.contains(_hud))
            {
                stage.removeChild(_hud);
            }

       }

Where HUDc extends MovieClip (along with the calling MovieClip) I'm not sure why Id be getting this error if I'm checking to see if the stage contains the movieclip?

Any takers?

Cheers

MikeW
  • 4,749
  • 9
  • 42
  • 83

1 Answers1

0

From the DisplayObjectContainer docs on contains:

Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, great-grandchildren, and so on each return true.

Just because stage "contains" _hud, doesn't mean that _hud is a direct child of stage. Give this a try instead:

if (_hud.parent != null)
{ _hud.parent.removeChild(_hud); }
meddlingwithfire
  • 1,437
  • 8
  • 12