Detecting the current state on a Spark List control item renderer in Flex 4

The following example shows how you can detect the current state on a Spark List control item renderer in Flex 4 by using the currentState 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_currentState_test"
    <s:List id="lst"
            horizontalCenter="0" verticalCenter="0">
            <s:VerticalLayout gap="0"
                    requestedRowCount="6" />
            <s:ArrayList source="[one,two,three,four,five,six,seven,eight,nine]" />

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

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:ItemRenderer name="CustomItemRen"
        <s:State name="normal" />
        <s:State name="hovered" />
        <s:State name="selected" />
        <s:State name="normalAndShowsCaret" />
        <s:State name="hoveredAndShowsCaret" />
        <s:State name="selectedAndShowsCaret" />
    <s:Label text="{itemIndex}) {currentState}"
            left="3" right="3" top="5" bottom="5" />


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.

3 thoughts on “Detecting the current state on a Spark List control item renderer in Flex 4

  1. This example is super lame and has nothing to do with state, as the title implies, but is only a rudimentary example of binding.

  2. HI,

    i made a gallery of images using LIST and itemRenderer for images.
    but i want to change the size of few images i.e, diff from remaining images , based on scroll position.

    so can any one give me some idea how to proceed

    i guess through listData and rowIndex but i m getting an error so if any one has example or idea please share it… thnx in advance

Comments are closed.