有人知道多列 VBox 示例吗?
只是想知道是否有人知道那里的示例,或者我可以添加到我的应用程序中的类,该类的性能类似于 VBox 但具有 2 列或更多列?
我从循环中向 VBox 添加项目,效果很好,但我希望将其分成两列:
_________________
| | |
| Item 1 | Item 2 |
| Item 3 | Item 4 |
| Item 5 | |
|________|________|
现在我只需并排设置 2 个 VBox,并将奇数项目分配给其中一个,然后即使对于另一个,但如果有一个控件自动执行此操作就好了。
编辑
请停止给我解决方法。我已经有了一个实用的解决方法。但是,如果您已经编写了一个这样做的课程,或者知道我可以在网上找到一个课程,我将非常感激。 谢谢
Just wondering if anyone knows of an example out there, or class I can add to my app that would perform like a VBox but with 2 or more columns?
I'm adding items to a VBox from a loop, and that works fine, but I want to have it split into two columns:
_________________
| | |
| Item 1 | Item 2 |
| Item 3 | Item 4 |
| Item 5 | |
|________|________|
For now I'm just going to set 2 VBoxes side by side and assign odd items to one, and even to the other, but it would be nice to have a control do this automatically.
EDIT
Please stop giving me work arounds. I already have a functional work around. But if you have already written a class that does this, or know where I can find one online I would really appreciate it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
flexlib (http://code.google.com/p/flexlib/) 有一个可爱的 FlowContainer 容器控件将完全满足您的需求。
flexlib (http://code.google.com/p/flexlib/) has a lovely FlowContainer container control that will do exactly what you need.
将它们放入 HBox 中?
put them in an HBox?
您可以使用每行包含一个 HBox 的 VBox,并简单地用 2 个项目填充每个 HBox,例如:
var vb:VBox;
var array_of_items:数组;
for(var i:int = 0; i < array_of_items.length; i+=2)
{
var hb:Hbox = new HBox();
hb.addChild(array_of_items[i]);
hb.addChild(array_of_items[i+1]);
vb.addChild(hb);
}
You could use a VBox containing an HBox for each row and simply populate each HBox with 2 items, something like:
var vb:VBox;
var array_of_items:Array;
for(var i:int = 0; i < array_of_items.length; i+=2)
{
var hb:Hbox = new HBox();
hb.addChild(array_of_items[i]);
hb.addChild(array_of_items[i+1]);
vb.addChild(hb);
}
我用一个 HBox 和 2 个表单做了类似的事情,这很好地排列了一切。
您可以动态地向每个表单交替添加子项。
I did something similar to this with an HBox and 2 forms, which lines things up nicely.
Dynamically, you could alternate adding children to each form.
为什么不直接使用 Tile Container,并将 Direction 属性设置为您所需的流向?
Why not just use the Tile Container, and set the direction property to your required flow direction?
我自己也有类似的问题。这就是我最终使用的:
但是,最终结果略有不同。它不是将子项移动到交替的列,而是无限期地填充第一列的高度,然后是第二列,然后是第三列,依此类推。
如果您计划创建我们的类,正如您所说,类似的方法应该有效:等待 CREATION_COMPLETE 事件,然后将子级重新排列到两个 VBox 控件中。
I had a similar problem myself. This is what I ended up using:
The end result is slightly different, however. Instead of moving children to alternating columns, it fills the height of the first column, then the second, then the third, etc. indefinitely.
If you plan on making your our Class, as you said, a similar approach should work: waiting for the CREATION_COMPLETE event, and then rearranging the children into two VBox controls.
我认为带有 Direction="horizontal" 的 Tile 容器就可以了
I think Tile container with direction="horizontal" will do it