I load a swf via the Loader() class. As the swf is loaded I loop through all the children of root and remove any TextField with removeChild(). This works initially - the TextField is removed. But as a tween in the loaded swf finishes and loops, the removed TextField somehow reappears. The TextField is Dynamic text. If I remove some StaticText, this stays removed. What is going on here?
loopChildren(root);
function loopChildren(dispObj:*):void {
for (var i:int = 0; i< dispObj.numChildren; i++) {
var obj:DisplayObject = dispObj.getChildAt(i);
if (obj is DisplayObjectContainer) {
loopChildren(obj);
}
else {
if (obj is TextField) {
obj.parent.removeChild(obj);
i--;
}
}
}
}
If I call loopChildren with a timer (5 sec intervall) and trace(obj.name) for all children, I notice that the obj.name changes. The TextField is called instance11, instance32, instance54 and so on. It seems that a new instance is created and added continuously?
EDIT: If I transfer the code directly to the swf and run it without using the wrapper it works as expected. I must be missing something that happens when its loaded through another movie?
EDIT2: I should say that the TextField I'm trying to remove is in a separate layer on the same time line as the tween. If I put the tween in its own timeline, it seems to work as expected. But can't dynamic text and tween live together?