Apache flex 有人知道多栏VBox示例吗?
只是想知道是否有人知道有一个例子,或者我可以添加到我的应用程序中的类,它的性能类似于VBox,但有两列或更多列 我正在从循环向VBox添加项,这很好,但我希望将其拆分为两列:Apache flex 有人知道多栏VBox示例吗?,apache-flex,actionscript-3,vbox,Apache Flex,Actionscript 3,Vbox,只是想知道是否有人知道有一个例子,或者我可以添加到我的应用程序中的类,它的性能类似于VBox,但有两列或更多列 我正在从循环向VBox添加项,这很好,但我希望将其拆分为两列: _________________ | | | | Item 1 | Item 2 | | Item 3 | Item 4 | | Item 5 | | |________|________| 现在,我只想并排设置2个VBox,并将奇数项分配给一个,甚至分配给另一个,但如果有一
_________________
| | |
| Item 1 | Item 2 |
| Item 3 | Item 4 |
| Item 5 | |
|________|________|
现在,我只想并排设置2个VBox,并将奇数项分配给一个,甚至分配给另一个,但如果有一个控件自动执行此操作,那就太好了
编辑请不要再给我安排工作。我已经安排了一个功能性的工作。但是如果你已经写了一个这样的类,或者知道我在哪里可以在线找到一个,我会非常感激。
谢谢将它们放入HBox?将它们放入HBox?您可以使用每行包含HBox的VBox,只需在每个HBox中填充两个项目,如: var-vb:VBox
变量数组\u的\u项:数组 对于(变量i:int=0;i
var hb:Hbox=新的Hbox();
hb.addChild(项目数组[i]);
hb.addChild(项目数组[i+1]);
vb.addChild(hb);
}
您可以使用一个VBox,每行包含一个HBox,只需在每个HBox中填充两个项目,如: var-vb:VBox
变量数组\u的\u项:数组 对于(变量i:int=0;i
var hb:Hbox=新的Hbox();
hb.addChild(项目数组[i]);
hb.addChild(项目数组[i+1]);
vb.addChild(hb);
}
我用一个HBox和两个表单做了类似的事情,它们把事情排得很好。
动态地,您可以交替地向每个表单添加子项。我用一个HBox和两个表单做了类似的事情,这使事情排列得很好。
动态地,您可以交替地向每个表单添加子项。为什么不直接使用磁贴容器,并将direction属性设置为所需的流动方向?为什么不直接使用磁贴容器,并将direction属性设置为所需的流动方向?我自己也有类似的问题。这就是我最终使用的:
package {
import mx.containers.HBox;
import mx.containers.VBox;
import mx.events.FlexEvent;
public class MultiColumnVBox extends HBox {
// public properties
public var columnWidth:int;
public var verticalGap:int;
public var adjustForScrollbar:Boolean;
public function MultiColumnVBox() {
super();
this.addEventListener(FlexEvent.CREATION_COMPLETE, rearrangeChildren);
}
private function rearrangeChildren(evtObj:FlexEvent):void {
// height will change whilst rearranging children, as will the Children Array
// we store them once at the start
var myHeight:int = this.height;
var children:Array = this.getChildren();
var lastIndex:int = 0;
var vBoxIndex:int = 0;
var vBox:VBox;
var totalHeight:int = -this.verticalGap + (this.adjustForScrollbar ? 16 : 0);
for(var i:int=0; i<children.length; i++) {
// resize each child and measure the height
// if you don't want it resized to the columnWidth, set the maxWidth property
children[i].width = this.columnWidth;
children[i].validateSize();
totalHeight += children[i].measuredHeight + this.verticalGap;
// if we're too tall, or we've reached the last element, move them into a VBox
if(totalHeight > myHeight || i == children.length-1) {
vBox = new VBox();
vBox.setStyle("verticalGap", this.verticalGap);
vBox.width = this.columnWidth;
// include last child if there is room
for(var j:int=lastIndex; j<(totalHeight > myHeight ? i : i+1); j++) {
vBox.addChild(children[j]);
}
this.addChildAt(vBox, vBoxIndex);
vBoxIndex += 1;
lastIndex = i;
totalHeight = -this.verticalGap + (this.adjustForScrollbar ? 16 : 0);
}
}
}
}
}
包{
导入mx.containers.HBox;
导入mx.containers.VBox;
导入mx.events.FlexEvent;
公共类多列VBox扩展HBox{
//公共财产
公共变量列宽:int;
公共垂直间隙:int;
公共var adjustForScrollbar:布尔值;
公共函数MultiColumnVBox(){
超级();
this.addEventListener(FlexEvent.CREATION_COMPLETE,重新排列子项);
}
私有函数(evtObj:FlexEvent):无效{
//在重新排列儿童时,高度会发生变化,儿童阵列也会发生变化
//我们一开始就存储一次
var myHeight:int=this.height;
var children:Array=this.getChildren();
var lastIndex:int=0;
var vBoxIndex:int=0;
var-vBox:vBox;
var totalHeight:int=-this.verticalGap+(this.adjustForScrollbar?16:0);
对于(var i:int=0;i我自己也有类似的问题。这就是我最终使用的:
package {
import mx.containers.HBox;
import mx.containers.VBox;
import mx.events.FlexEvent;
public class MultiColumnVBox extends HBox {
// public properties
public var columnWidth:int;
public var verticalGap:int;
public var adjustForScrollbar:Boolean;
public function MultiColumnVBox() {
super();
this.addEventListener(FlexEvent.CREATION_COMPLETE, rearrangeChildren);
}
private function rearrangeChildren(evtObj:FlexEvent):void {
// height will change whilst rearranging children, as will the Children Array
// we store them once at the start
var myHeight:int = this.height;
var children:Array = this.getChildren();
var lastIndex:int = 0;
var vBoxIndex:int = 0;
var vBox:VBox;
var totalHeight:int = -this.verticalGap + (this.adjustForScrollbar ? 16 : 0);
for(var i:int=0; i<children.length; i++) {
// resize each child and measure the height
// if you don't want it resized to the columnWidth, set the maxWidth property
children[i].width = this.columnWidth;
children[i].validateSize();
totalHeight += children[i].measuredHeight + this.verticalGap;
// if we're too tall, or we've reached the last element, move them into a VBox
if(totalHeight > myHeight || i == children.length-1) {
vBox = new VBox();
vBox.setStyle("verticalGap", this.verticalGap);
vBox.width = this.columnWidth;
// include last child if there is room
for(var j:int=lastIndex; j<(totalHeight > myHeight ? i : i+1); j++) {
vBox.addChild(children[j]);
}
this.addChildAt(vBox, vBoxIndex);
vBoxIndex += 1;
lastIndex = i;
totalHeight = -this.verticalGap + (this.adjustForScrollbar ? 16 : 0);
}
}
}
}
}
包{
导入mx.containers.HBox;
导入mx.containers.VBox;
导入mx.events.FlexEvent;
公共类多列VBox扩展HBox{
//公共财产
公共变量列宽:int;
公共垂直间隙:int;
公共var adjustForScrollbar:布尔值;
公共函数MultiColumnVBox(){
超级();
this.addEventListener(FlexEvent.CREATION_COMPLETE,重新排列子项);
}
私有函数(evtObj:FlexEvent):无效{
//在重新排列儿童时,高度会发生变化,儿童阵列也会发生变化
//我们一开始就存储一次
var myHeight:int=this.height;
var children:Array=this.getChildren();
var lastIndex:int=0;
var vBoxIndex:int=0;
var-vBox:vBox;
var totalHeight:int=-this.verticalGap+(this.adjustForScrollbar?16:0);
for(var i:int=0;iflexlib()有一个可爱的FlowContainer控件,可以完全满足您的需要。flexlib()有一个可爱的FlowContainer控件,可以完全满足您的需要。我认为direction=“horizontal”的平铺容器可以满足您的需要。我认为direction=“horizontal”的平铺容器will do it看我的小图,我不想让它们全部水平排列,我想要两个垂直柱我以为你想让它们水平排列两个垂直柱。看我的小图,我不想让它们全部水平排列,我想要两个垂直柱我以为你想让它们水平排列两个垂直柱。这与我是l已经在做了,但这是一个很好的代码示例,说明了如何做:-)我只是希望在一个组件中完成。您的示例的问题是,我的项目的长度会有所不同,并且使用这种布局,如果不专门设置一些宽度,它们将不会在格式良好的列中。这与我已经在做的类似,但这是一个很好的代码示例,说明了如何完成:-)我只是希望在一个组件中实现这一点。您的示例的问题是,我的项目在长度上会有所不同,使用这种布局,如果不专门设置一些宽度,它们将不会在格式良好的列中。将两个类似的列表并排放置并交替添加内容如何?setvariableRowHeight=“false”
否则,高度可能会根据内容而变化。在这种情况下,我还必须有项目渲染器,我以前没有说过,但我有一个标签,每个项目有一组3个收音机。看起来更简单的是,我要交替添加两个VBox。(使用标签和HBox中的收音机将HBox添加到其中一个VBox中).我不是在寻求如何做到这一点的帮助,我可以用现有的类实现我想要的,只是