Setting the border alpha on a Panel container in Flex

by Peter deHaan on March 12, 2008

in Panel

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

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/12/setting-the-border-alpha-on-a-panel-container-in-flex/ -->
<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("borderAlpha");
            }

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

    <mx:ApplicationControlBar dock="true">
        <mx:Label text="borderAlpha:" />
        <mx:HSlider id="slider"
                minimum="0.0"
                maximum="1.0"
                liveDragging="true"
                snapInterval="0.1"
                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>

View source is enabled in the following example.

For an example on setting the Panel container’s background alpha, see “Setting the background alpha on a Panel container in Flex”.

{ 2 comments… read them below or add one }

1 Marko March 16, 2008 at 4:05 pm

Nice one, thanks!

Reply

2 urig December 1, 2008 at 2:52 am

hey,
there seems to be an inconsistency relating to ‘border’ in the panel container.
borderColor refers to the vector outline (line/stroke) of the panel window, but border alpha here sets the alpha for the entire window edges, not just a line.
any idea how to control the alpha of the line only?

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can 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

Previous post:

Next post: