Search code examples
actionscript-3removechildaddchilddisplayobject

AS3 stage.addChild / stage.removeChild << Must be child of caller


If im usin function to add a mc to the stage like so:

var myChild:MC= new MC();

function somefunc()
{
   stage.addChild(myMC)
}

but when I try to remove the mc by:

stage.removeChild(myMC)

I get The supplied DisplayObject must be a child of the caller error... any suggestions or work arounds?


Solution

  • You could try hiding and showing the movieClip, if possible. I think its a bit faster than removing and adding consistantly, code permitting. Keep in mind this is just a suggestion, someone smarter than me outta be able to help you out..