开发者

Select all MovieClips instances with code

开发者 https://www.devze.com 2022-12-17 21:34 出处:网络
Supose I have a MovieClip called Egg and I have a lot of Egg instances with unique names (required) or without names.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号