質問

だかなら誰でも知っている例があり、クラスで追加できます私のアプリを行いようにVBoxが2つ以上のカラム?

私の追加アイテムを例文、ネイティブVBoxからループは、作品がいいの割合で二つのカラムを持ちます:

 _________________
|        |        |
| Item 1 | Item 2 |
| Item 3 | Item 4 |
| Item 5 |        |
|________|________|

今ろしに行くって言ったじゃないセット2VBoxes並びに割り当てが奇数項目についても、その他のものように管理います。

編集
停止してくださいこの作品arounds. すでに持っている機能です。だいているクラスはこのタウンで見つけオンラインことに感謝しています。感謝

役に立ちましたか?

解決

flexlib( http://code.google.com/p/flexlib/する )正確に何が必要でしょう素敵なFlowContainerコンテナコントロールを持っています。

他のヒント

のHBox?

に入れて

あなたは、行ごとのHBoxを含むVBoxのを使用して、単純に2つの項目、のようなもので、それぞれのHBoxを移入できます:

のvar VB:VBoxの、
VaRのarray_of_items:配列;

以下のための

(VAR I:INT = 0; I {
  VaRのHB:のhbox =新しいのHBox();
  hb.addChild(array_of_items [I]);
  hb.addChild(array_of_items [I + 1]);
  vb.addChild(HB);
}

私は、HBoxの2つの形でこれに似た何かをしたどのうまく行物事を。 動的に、あなたは、各フォームに子を追加交互ことができます。

なぜちょうどタイルコンテナを使用し、あなたの必要な流れの方向に方向プロパティを設定していない?

私は同様の問題を自分で持っていました。これは私が使用して終了するものである。

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

は最終的な結果は、しかし、わずかに異なっています。代わりに列を交互に子供を移動させる、それは無期限等次いで、最初の列の高さ、第二、第三に、充填されている。

あなたは私たちのクラスを作ることに計画している場合は、あなたが言ったように、

、、同様のアプローチが動作するはずです:CREATION_COMPLETEイベントを待って、その後、2つのVBoxコントロールに子供たちを並べ替える

私は方向を持つTileコンテナは=「水平」はそれを行うだろうと思います。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top