Actionscript 3 for..Adobe air窗体控件的每个循环

Actionscript 3 for..Adobe air窗体控件的每个循环,actionscript-3,air,Actionscript 3,Air,我有四个AdobeAIR表单中的TextInput控件。 它们显示在一个名为pnlUnlockCode的面板中 现在我要做的是为这四个TextInput实现一个for..each循环 foreach (Control c in this.Controls) { c.Height = this.Height * (sizes[count].Height / SCALE_H); c.Width = this.Width * (sizes[count].Width / SCALE_W)

我有四个AdobeAIR表单中的TextInput控件。 它们显示在一个名为pnlUnlockCode的面板中

现在我要做的是为这四个TextInput实现一个for..each循环

foreach (Control c in this.Controls)
{
    c.Height = this.Height * (sizes[count].Height / SCALE_H);
    c.Width = this.Width * (sizes[count].Width / SCALE_W);
    c.Left = this.Width * (positions[count].X / SCALE_W);
    c.Top = this.Height * (positions[count].Y / SCALE_H);
}
在c#中

请帮我解决这个问题

等待您的回复


谢谢

您可以执行以下操作:

for( var i:int=0; i < pnlUnlockCode.numElements; i++){
   var c:TextInput in pnlUnlockCode.getElementAt(i)
   ...
}
for(变量i:int=0;i
这就是我要尝试的:

var numControls : uint = pnlUnlockCode.numChildren;
for (var i : uint; i < numControls; i++) {
    var control : TextInput = pnlUnlockCode.getChildAt(i) as TextInput;
    control.setActualSize(sizes[count].Width / SCALE_W, sizes[count].Height / SCALE_H);
    control.move(positions[count].X / SCALE_W, positions[count].Y / SCALE_H);
}

是否有人可以确认这一点?

pnlUnlockCode的“getChildren”不存在。Getting 1061:通过静态类型spark的引用调用可能未定义的方法getChildren。组件:Panel.Yo
getChildren()
不是显示对象容器方法。改为使用
numChildren
getChildAt
。对于spark容器,getChildAt不再存在。更新了使用getElementAt insteadOha的示例代码!如何防止在DisplayObjectContainer的子类中使用
getChildAt
?我想最好的方法是单独设置它们。setActualSize似乎还有其他用途。Flex在考虑百分比、默认值、最小值或最大值以及布局规则的情况下,在相当复杂的“布局过程”中计算组件的大小。此过程的结果为实际尺寸。您可以自行设置,但如果这样做,Flex将在下一个布局过程中重置(重新计算)。
control.width = ...;
control.height = ...;