The following example shows how you can toggle item roll over highlighting on a Flex List control by setting the useRollOver style.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/20/toggling-item-roll-over-highlighting-on-a-list-control-in-flex/ -->
<mx:Application name="List_useRollOver_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Array id="arr">
        <mx:Object label="Button"
                icon="@Embed('assets/Button.png')" />
        <mx:Object label="ButtonBar"
                icon="@Embed('assets/ButtonBar.png')" />
        <mx:Object label="CheckBox"
                icon="@Embed('assets/CheckBox.png')" />
        <mx:Object label="ColorPicker"
                icon="@Embed('assets/ColorPicker.png')" />
        <mx:Object label="ComboBox"
                icon="@Embed('assets/ComboBox.png')" />
        <mx:Object label="DataGrid"
                icon="@Embed('assets/DataGrid.png')" />
        <mx:Object label="DateChooser"
                icon="@Embed('assets/DateChooser.png')" />
        <mx:Object label="DateField"
                icon="@Embed('assets/DateField.png')" />
        <mx:Object label="HorizontalList"
                icon="@Embed('assets/HorizontalList.png')" />
        <mx:Object label="HRule"
                icon="@Embed('assets/HRule.png')" />
        <mx:Object label="HScrollBar"
                icon="@Embed('assets/HScrollBar.png')" />
        <mx:Object label="HSlider"
                icon="@Embed('assets/HSlider.png')" />
    </mx:Array>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="useRollOver:">
                <mx:CheckBox id="checkBox" selected="true" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:List id="list"
            dataProvider="{arr}"
            useRollOver="{checkBox.selected}"
            verticalScrollPolicy="on"
            width="150" />

</mx:Application>
 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree