Once you remove parentMC
and set it as null
, garbage collection will take care of its children.
When you remove the parent from the Flash display list hierarchy its children won't exist in the display list. You could remove children before you remove the parent from the display list, but that isn't necessary unless you wish to move the child to another container. But when you call addChild
on the second parent (parentMC2.addChild(child1)
) it will be automatically removed from parentMC
. Assuming that parentMC
does not hold any variables linking to the child1
instance, you are safe.
If your children listening to Event.REMOVED_FROM_STAGE
and you would like to make a dispose function for your parent you could simply remove all the children from the parent one by one:
while( parent.numChildren > 0 ) parent.removeChildAt( 0 );
and then execute your dispose code after all the children have been removed. But yet again unless it's absolutely necessary for your program logic it would be a waste of time