AS3 - 不显示子项
我有一个名为 BoxContainer 的容器符号。这可能包含未知数量的单选按钮组件。为了添加这些,我有一组称为框的单选按钮。这是 CheckBoxes 类的一部分。
这是我的问题:当我从框架本身将单选按钮作为子项添加到舞台时,它工作得很好。但是,我需要将其添加到 BoxContainer 影片剪辑中。我尝试过:
在框架上:
for(var i in Checkbox.boxes)
{
BoxContainer.addChild(Checkbox.boxes[i]);
}
在盒子容器对象上
for(var i in Checkbox.boxes)
{
addChild(Checkbox.boxes[i]);
}
但是,这两种方法都不起作用。当我运行闪光灯时,单选按钮不可见。我该如何解决这个问题?
I have a container symbol called BoxContainer. This can contain an unknown number of Radio Button components. To add these, I have an array of Radio Buttons called boxes. This is part of the CheckBoxes class.
Here's my problem: When I add the radio buttons as children to the stage, from the frame itself, it works just fine. However, I need to add it to the BoxContainer movie clip. I have tried:
On the frame:
for(var i in Checkbox.boxes)
{
BoxContainer.addChild(Checkbox.boxes[i]);
}
On the box container object
for(var i in Checkbox.boxes)
{
addChild(Checkbox.boxes[i]);
}
However, both of these do not work. When I run the flash, the radio buttons are not visible. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,“boxes”是 Checkbox 类的静态成员吗?这似乎是一个奇怪的设置,但我假设确实如此。另外,请考虑将“BoxContainer”重命名为“boxContainer”,因为带有首字母大写的名称被假定为类,而不是标准 AS3 命名约定中的对象。
您使用的 for...in 循环将不起作用,因为 i 成为对数组中对象的引用,而不是数组的索引。考虑使用数字 for 循环:
First, is "boxes" a static member of the Checkbox class? It seems like an odd setup, but I'll assume that it is. Also, consider renaming "BoxContainer" to "boxContainer" as names with initial-caps are assumed to be classes, not objects in standard AS3 naming conventions.
The
for...in
loop you're using is not going to work becausei
becomes a reference to the object in the array, not the index of the array. Consider using a numeric for loop: