Avg. Rating 2.0

Problem

You want to set the background alpha on a Panel container.

Solution

The following example shows how you can set the background alpha on a Flex Panel container by setting the backgroundAlpha style.

Detailed explanation

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        creationComplete="init();">
 
    <mx:Style>
        Application {
            backgroundColor: red;
            backgroundGradientColors: red, black;
        }
    </mx:Style>
 
    <mx:Script>
        <![CDATA[
            import mx.events.SliderEvent;
 
            private function init():void {
                slider.value = panel.getStyle("backgroundAlpha");
            }
 
            private function slider_change(evt:SliderEvent):void {
                panel.setStyle("backgroundAlpha", evt.value);
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Label text="backgroundAlpha:" />
        <mx:HSlider id="slider"
                minimum="0.0"
                maximum="1.0"
                liveDragging="true"
                snapInterval="0.01"
                tickInterval="0.1"
                change="slider_change(event);" />
    </mx:ApplicationControlBar>
 
    <mx:Panel id="panel" title="Panel" width="100%" height="100%">
        <mx:ControlBar>
            <mx:Label text="ControlBar" />
        </mx:ControlBar>
    </mx:Panel>
 
</mx:Application>

For more information, see http://blog.flexexamples.com/2008/03/12/setting-the-background-alpha-on-a-panel-container-in-flex/.

Report abuse

Related recipes