The following example shows how you can toggle the drop shadow on a Flex Panel container by setting the dropShadowEnabled style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/19/toggling-the-drop-shadow-on-a-panel-container-in-flex/ -->
<mx:Application name="Panel_dropShadowEnabled_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="dropShadowEnabled:"
                labelPlacement="left"
                selected="true" />
    </mx:ApplicationControlBar>

    <mx:Panel id="panel"
            title="Panel title"
            width="100%"
            height="100%"
            borderColor="haloSilver"
            dropShadowEnabled="{checkBox.selected}">
        <mx:Label text="Panel contents" />
    </mx:Panel>

</mx:Application>

View source is enabled in the following example.

You can also set the dropShadowEnabled style in an external .CSS file or <mx:Style /> block, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/19/toggling-the-drop-shadow-on-a-panel-container-in-flex/ -->
<mx:Application name="Panel_dropShadowEnabled_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        Panel {
            border-color: haloSilver;
            dropShadowEnabled: false;
        }
    </mx:Style>

    <mx:Panel id="panel"
            title="Panel title"
            width="100%"
            height="100%">
        <mx:Label text="Panel contents" />
    </mx:Panel>

</mx:Application>

Or, you can set the dropShadowEnabled style using ActionScript, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/19/toggling-the-drop-shadow-on-a-panel-container-in-flex/ -->
<mx:Application name="Panel_dropShadowEnabled_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function checkBox_change(evt:Event):void {
                panel.setStyle("dropShadowEnabled", checkBox.selected);
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="dropShadowEnabled:"
                labelPlacement="left"
                selected="true"
                change="checkBox_change(event);" />
    </mx:ApplicationControlBar>

    <mx:Panel id="panel"
            title="Panel title"
            width="100%"
            height="100%"
            borderColor="haloSilver">
        <mx:Label text="Panel contents" />
    </mx:Panel>

</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.

One Response to Toggling the drop shadow on a Panel container in Flex

  1. Why this web site do not have other languages support?

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