views:

23

answers:

1

Hi

Supose I have a MovieClip called Egg and I have a lot of Egg instances with unique names (required) or without names.

What if I need to write a code who break all these eggs refering to the Main object in Library? Instead to add code for every egg with every name in the Stage.

This is possible?

Thanks

A: 

If I understand you correctly, this should work:

for (var index:int = Main.numChildren-1; index >= 0; index--){
    var element = Main.getChildAt(index);
    if (element is Egg) {
        element.break();
    }
}

'Main' is an instance that holds all your Eggs (and possibly other stuff). This iterates through everything in Main and if it's an Egg, it breaks it.

Wallacoloo
Thanks a lot wallacoloo this solve the main doubt but.¿What if I want to change the eggs width to 400px??????.width = 400;¿Where and how I put the line of code?Thanks.
Deryck
Then you'd replace 'element.break();' with 'element.width = 400;'
Wallacoloo
You´re my hero dude! Thanks a lot!
Deryck