Creating a variable row height Spark DropDownList control in Flex 4

In a previous example, “Creating a variable row height item renderer on a ComboBox control in Flex”, we saw how you could create a variable row height item renderer on a Flex MX ComboBox control by setting the variableRowHeight property on the ComboBox control’s dropdown property.

The following example shows how you can create a variable row height Spark DropDownList control in Flex 4 by setting a custom VerticalLayout object and setting the Boolean variableRowHeight property and the horizontalAlign property.

Full code after the jump.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_DropDownList_layout_variableRowHeight_test"
    <s:DropDownList id="ddl"
            <s:VerticalLayout gap="0"
                    horizontalAlign="justify" />
                <fx:Array id="arr">
                    <fx:Object name="Baltimore Orioles" abbr="BAL" />
                    <fx:Object name="Boston Red Sox" abbr="BOS" />
                    <fx:Object name="Chicago White Sox" abbr="CWS" />
                    <fx:Object name="Cleveland Indians" abbr="CLE" />
                    <fx:Object name="Detroit Tigers" abbr="DET" />
                    <fx:Object name="Kansas City Royals" abbr="KC" />
                    <fx:Object name="Los Angeles Angels of Anaheim" abbr="LAA" />
                    <fx:Object name="Minnesota Twins" abbr="MIN" />
                    <fx:Object name="New York Yankees" abbr="NYY" />
                    <fx:Object name="Oakland Athletics" abbr="OAK" />
                    <fx:Object name="Seattle Mariners" abbr="SEA" />
                    <fx:Object name="Tampa Bay Devil Rays" abbr="TB" />
                    <fx:Object name="Texas Rangers" abbr="TEX" />
                    <fx:Object name="Toronto Blue Jays" abbr="TOR" />

This entry is based on a beta version of the Flex 4 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 4 SDK.