Setting the layout direction on an FxList control in Flex Gumbo

The following examples show how you can set the layout direction on a Flex Gumbo FxList control by setting the layout property to a VerticalLayout object (default), HorizontalLayout object, or a TileLayout object.

Full code after the jump.

To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3″.

By default the FxList control uses a vertical layout, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/24/setting-the-layout-direction-on-an-fxlist-control-in-flex-gumbo/ -->
<FxApplication name="FxList_layout_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        backgroundColor="white">

    <FxList id="list"
            horizontalCenter="0"
            verticalCenter="0"
            width="150"
            height="100">
        <dataProvider>
            <ArrayCollection>
                <String>1. The</String>
                <String>2. Quick</String>
                <String>3. Brown</String>
                <String>4. Fox</String>
                <String>5. Jumps</String>
                <String>6. Over</String>
                <String>7. The</String>
                <String>8. Lazy</String>
                <String>9. Dog</String>
            </ArrayCollection>
        </dataProvider>
    </FxList>

</FxApplication>

If you wanted to use a horizontal layout simply set the layout property to a HorizontalLayout object, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/24/setting-the-layout-direction-on-an-fxlist-control-in-flex-gumbo/ -->
<FxApplication name="FxList_layout_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        backgroundColor="white">

    <FxList id="list"
            horizontalCenter="0"
            verticalCenter="0"
            width="150"
            height="100">
        <layout>
            <HorizontalLayout gap="0" />
        </layout>
        <dataProvider>
            <ArrayCollection>
                <String>1. The</String>
                <String>2. Quick</String>
                <String>3. Brown</String>
                <String>4. Fox</String>
                <String>5. Jumps</String>
                <String>6. Over</String>
                <String>7. The</String>
                <String>8. Lazy</String>
                <String>9. Dog</String>
            </ArrayCollection>
        </dataProvider>
    </FxList>

</FxApplication>

Or, if you wanted to use a tile layout (similar to a Halo TileList control) simply set the layout property to a TileLayout object, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/24/setting-the-layout-direction-on-an-fxlist-control-in-flex-gumbo/ -->
<FxApplication name="FxList_layout_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        backgroundColor="white">

    <FxList id="list"
            horizontalCenter="0"
            verticalCenter="0"
            width="150"
            height="100">
        <layout>
            <TileLayout horizontalGap="0" verticalGap="0" />
        </layout>
        <dataProvider>
            <ArrayCollection>
                <String>1. The</String>
                <String>2. Quick</String>
                <String>3. Brown</String>
                <String>4. Fox</String>
                <String>5. Jumps</String>
                <String>6. Over</String>
                <String>7. The</String>
                <String>8. Lazy</String>
                <String>9. Dog</String>
            </ArrayCollection>
        </dataProvider>
    </FxList>

</FxApplication>

This entry is based on a beta version of the Flex Gumbo SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Gumbo SDK.