Creating a tile layout Spark DropDownList control in Flex 4

The following example shows how you can create a Spark DropDownList with a tile layout in Flex 4 by setting the layout property to a TileList object.

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_TileLayout_test"
    <s:DropDownList id="dropDownList"
                <fx:Object label="The" />
                <fx:Object label="Quick" />
                <fx:Object label="Brown" />
                <fx:Object label="Fox" />
                <fx:Object label="Jumps" />
                <fx:Object label="Over" />
                <fx:Object label="The" />
                <fx:Object label="Lazy" />
                <fx:Object label="Dog" />

And the custom skin class, skins/CustomDropDownListSkin.mxml, is as follows

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Skin name="CustomDropDownListSkin"
    <!-- states -->
        <s:State name="normal" />
        <s:State name="open" />
        <s:State name="disabled" />
    <!-- host component -->
    <!--- The PopUpAnchor control that opens the drop-down list. -->
    <s:PopUpAnchor id="popUp"  displayPopUp.normal="false""true" includeIn="open"
            left="0" right="0" top="0" bottom="0" itemDestructionPolicy="auto"
            popUpPosition="below" popUpWidthMatchesAnchorWidth="false">
        <!--- The drop down area of the skin. This includes borders, background colors, scrollers, and filters. -->
        <s:Group id="dropDown" maxHeight="134" minHeight="22" >
            <!-- drop shadow -->
            <s:RectangularDropShadow blurX="20" blurY="20" alpha="1.0" distance="5" 
                 angle="90" color="#000000" left="0" top="0" right="0" bottom="0"/>
            <!-- border -->
            <s:Rect left="0" right="0" top="0" bottom="0">
                    <s:SolidColorStroke color="0x686868" weight="1"/>
            <!-- fill -->
            <!--- Defines the appearance of drop-down list's background fill. -->
            <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
                    <!--- The color of the drop down's background fill. The default color is 0xFFFFFF. -->
                    <s:SolidColor id="bgFill" color="0xFFFFFF" />
            <s:Scroller left="0" top="0" right="0" bottom="0" focusEnabled="false"
                    minViewportInset="1" verticalScrollPolicy="on">
                <!--- The container for the data items in the drop-down list. -->
                <s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
                        <s:TileLayout horizontalGap="0" verticalGap="0"
                                requestedColumnCount="3" requestedRowCount="2" columnWidth="100" />
    <!--- The anchor button used by the DropDownList. The default skin is DropDownListButtonSkin. -->
    <s:Button id="openButton" left="0" right="0" top="0" bottom="0" focusEnabled="false"
            skinClass="spark.skins.spark.DropDownListButtonSkin" />
    <!--- The prompt area of the DropDownList. -->
    <s:SimpleText id="labelDisplay" verticalAlign="middle" maxDisplayedLines="1"
            left="7" right="30" top="2" bottom="2" verticalCenter="1" /> 

View source is enabled in the following example.

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.

4 thoughts on “Creating a tile layout Spark DropDownList control in Flex 4

  1. Yeah, 90% of the Gumbo examples are missing the SWFs. It was just too much work to make/upload SWFs and then have to do it again and again as the API changes.

    For the most part these examples are really easy to build in Flash Builder 4 beta, for anybody interested.


  2. Hi Peter, i have a problem with the tilelist image. In the image’s source tag i had decoded the base64 value to byte array ..but it is not loading.When im using button click it loads.. pls do reply

    The code is like this,

    thanks in advance


Comments are closed.