The OOP issue is that you're losing your objects and you have to look them up by their depths. I'm not sure what the scope of this is but if you are going to need an object later, its a good idea to store it in a var/array at a scope outside the function it's built in.
Here's a quick rewrite:
PHP Code:var myNewObj:Sprite = new Sprite();
main.addChild(myNewObj);
var i:int = main.numChildren; // loop variant
var child:DisplayObject; // to be used in the loop
while(i > 0){
i--;
// grab the display object
child = main.getChildAt(i);
// test if it's a TF
if(child is TextField){
// if so trace it
// remember that it's cast to DO, not TF!!
trace(child);
}
}




Reply With Quote