简体   繁体   English

FLASH-选择“ button1”的button [1]

[英]FLASH - button[1] selection of “button1”

Always wanted to know if this was possible, and how to do it, but I have no idea what to search for or what it's called. 一直想知道这是否可行以及如何实现,但是我不知道要搜索什么或称它为什么。

Let me give you an example: 让我给你举个例子:

Lets say I've got 3 buttons. 可以说我有3个按钮。

"btn001" "btn002" "btn003" “ btn001”“ btn002”“ btn003”

If I want to add an eventlistener to these, is it possible to do it in a for loop (without having to put them to an array first). 如果我想向其中添加一个事件监听器,是否可以在for循环中进行(而不必先将它们放入数组)。 I want to do this so that I can add/remove buttons on my stage, and just update a variable telling me how many buttons there are. 我想这样做,以便可以在舞台上添加/删除按钮,并且只需更新一个变量即可告诉我有多少个按钮。

For example like this: 例如这样:

for(var i:int = 0; i<numBtns;i++){
    btn00[i].addEventListener(bla bla bla bla...);
}

Any ideas? 有任何想法吗? =) =)

不是像您编写它们那样,而是如果将它们全部添加到公共父级中,则可以遍历父级的子级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM