The following example shows how you can change the background fill alpha on a HorizontalList control in Flex by setting the backgroundAlpha style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/04/changing-the-background-alpha-of-a-horizontallist-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();">

    <mx:Style>
        Application {
            backgroundGradientColors: red, black;
        }
    </mx:Style>

    <mx:Script>
        <![CDATA[
            import mx.events.SliderEvent;

            private function init():void {
                slider.value = horizontalList.getStyle("backgroundAlpha");
            }

            private function slider_change(evt:SliderEvent):void {
                horizontalList.setStyle("backgroundAlpha", evt.value);
            }
        ]]>
    </mx:Script>

    <mx:Array id="arr">
        <mx:Object label="Accordion" />
        <mx:Object label="ApplicationControlBar" />
        <mx:Object label="Box" />
        <mx:Object label="Canvas" />
        <mx:Object label="ControlBar" />
        <mx:Object label="DividedBox" />
        <mx:Object label="Form" />
        <mx:Object label="FormHeading" />
        <mx:Object label="FormItem" />
        <mx:Object label="Grid" />
        <mx:Object label="HBox" />
        <mx:Object label="HDividedBox" />
        <mx:Object label="Panel" />
        <mx:Object label="TabNavigator" />
        <mx:Object label="Tile" />
        <mx:Object label="TitleWindow" />
        <mx:Object label="VBox" />
        <mx:Object label="VDividedBox" />
        <mx:Object label="ViewStack" />
    </mx:Array>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="backgroundAlpha:">
                <mx:HSlider id="slider"
                        minimum="0.0"
                        maximum="1.0"
                        liveDragging="true"
                        tickInterval="0.1"
                        change="slider_change(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:HorizontalList id="horizontalList"
            dataProvider="{arr}"
            backgroundAlpha="1.0"
            backgroundColor="haloSilver"
            columnWidth="175"
            columnCount="3"
            rowCount="1"
            rowHeight="100" />

</mx:Application>

View source is enabled in the following example.

 
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