Setting the background fill alpha on a Halo DataGrid control in Flex 4

The following example shows how you can set the background alpha on a Halo DataGrid control in Flex 4 by setting the contentBackgroundAlpha style and setting the alternatingItemColors style to an empty array.

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 www.adobe.com/products/flex/. To download the latest nightly build of the Flex 4 SDK, see opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.

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"?>
<!-- http://blog.flexexamples.com/2009/10/25/setting-the-background-fill-alpha-on-a-halo-datagrid-control-in-flex-4/ -->
<s:Application name="Halo_DataGrid_contentBackgroundAlpha_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">
    <s:controlBarContent>
        <mx:Form styleName="plain" backgroundAlpha="0.0">
            <mx:FormItem label="contentBackgroundAlpha:">
                <s:HSlider id="sl"
                        minimum="0.0"
                        maximum="1.0"
                        value="1.0"
                        stepSize="0.1"
                        snapInterval="0.1" />
            </mx:FormItem>
        </mx:Form>
    </s:controlBarContent>
 
    <s:Panel title="Panel title"
            backgroundColor="yellow"
            horizontalCenter="0" verticalCenter="0">
        <mx:DataGrid id="dtGrd"
                contentBackgroundColor="red"
                contentBackgroundAlpha="{sl.value}"
                alternatingItemColors="[]"
                rowCount="6"
                left="20" right="20" top="20" bottom="20">
            <mx:dataProvider>
                <mx:ArrayList>
                    <mx:source>
                        <fx:Object c1="1.One" c2="1.Two" />
                        <fx:Object c1="2.One" c2="2.Two" />
                        <fx:Object c1="3.One" c2="3.Two" />
                        <fx:Object c1="4.One" c2="4.Two" />
                        <fx:Object c1="5.One" c2="5.Two" />
                        <fx:Object c1="6.One" c2="6.Two" />
                        <fx:Object c1="7.One" c2="7.Two" />
                        <fx:Object c1="8.One" c2="8.Two" />
                        <fx:Object c1="9.One" c2="9.Two" />
                    </mx:source>
                </mx:ArrayList>
            </mx:dataProvider>
        </mx:DataGrid>
    </s:Panel>
 
</s:Application>

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.