Creating a radio button item renderer on a Spark List control in Flex 4

The following example shows how you can use a Spark RadioButton control as an item renderer for a Spark List control in Flex 4 by setting the itemRenderer property.

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_List_itemRenderer_RadioButton_test"
        <s:Label text="selected RadioButton: {dgr1.selection.label}" />
        <s:RadioButtonGroup id="dgr1" selectedValue="Three" />
    <s:List id="lst"
            horizontalCenter="0" verticalCenter="0">
            <s:VerticalLayout gap="0"
                    requestedRowCount="6" />
                <fx:Object val="One" gr="{dgr1}" />
                <fx:Object val="Two" gr="{dgr1}" />
                <fx:Object val="Three" gr="{dgr1}" />
                <fx:Object val="Four" gr="{dgr1}" />
                <fx:Object val="Five" gr="{dgr1}" />
                <fx:Object val="Six" gr="{dgr1}" />
                <fx:Object val="Seven" gr="{dgr1}" />
                <fx:Object val="Eight" gr="{dgr1}" />
                <fx:Object val="Nine" gr="{dgr1}" />

And the custom Spark List item renderer, skins/RadioButtonItemRen.mxml, is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:ItemRenderer name="RadioButtonItemRen"
            protected function itemrenderer1_dataChangeHandler(evt:Event):void {
                rdBtn.label = data.val;
                rdBtn.value = data.val;
    <s:RadioButton id="rdBtn"
            left="3" right="3" top="5" bottom="5" />

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.

One thought on “Creating a radio button item renderer on a Spark List control in Flex 4

  1. What if the data comes from an XML file? How do you pass the RadioButtonGroup to the itemRenderer. I’ve literally tried everything. Help!!!

Comments are closed.