开发者

Select all MovieClips instances with code

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜