如何更改默认的mx:表单布局?

时间:2011-03-15 10:50:50

标签: flex forms layout flex4

我需要在表单上使用水平布局,它们看起来像这样:

<mx:Form id="myForm" width="100%">
    <mx:FormItem label="Color">
        <s:ComboBox id="color"> 
            <s:dataProvider>
                <mx:ArrayList>
                    <fx:String>Red</fx:String>
                    <fx:String>Orange</fx:String>
                    <fx:String>Yellow</fx:String>
                    <fx:String>Blue</fx:String>
                    <fx:String>Green</fx:String>
                </mx:ArrayList>
            </s:dataProvider>
        </s:ComboBox>
    </mx:FormItem>
</mx:Form>

我对新的Flex 4架构非常困惑......

1 个答案:

答案 0 :(得分:2)

默认情况下,Form组件将始终垂直布置其子项。如果您想要水平布局,则必须扩展Form类。试试这个:

<强> Horizo​​ntalForm.as

package
{
    import mx.containers.BoxDirection;
    import mx.containers.Form;
    import mx.core.mx_internal;

    public class HorizontalForm extends Form
    {
        public function HorizontalForm()
        {
            super();
            mx_internal::layoutObject.direction = BoxDirection.HORIZONTAL;
        }
    }
}