开发者

for..each loop for Adobe air form controls

I have four TextInput controls in a adobe air form. They are showing in a panel named : pnlUnlockCode.

Now what I want to do is to implement a for..each loop for these four TextInput like

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 * (position开发者_Go百科s[count].Y / SCALE_H);
}

in c#.

Please pull me from this problem.

Awaiting your response.

Thanks


You can do the following:

for( var i:int=0; i < pnlUnlockCode.numElements; i++){
   var c:TextInput in pnlUnlockCode.getElementAt(i)
   ...
}


This is what I would try:

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);
}

Note, you can apply scalings also by setting the scaleX, scaleY properties of a display object.

And here another note:

setActualSize(w, h) sets the size apparently not reliably. I cound not find any Flex method to set widht and height in one run. So you perhaps will be better to use the width and height properties individually:

control.width = ...;
control.height = ...;

Could someone confirm this?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜