The following example shows how you can toggle the drop shadow on the Flex ComboBox control by setting the dropShadowEnabled style on the ComboBox control’s dropdown menu.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/09/toggling-the-drop-shadow-on-the-combobox-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="horizontal"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        .shadowDisabled {
            dropShadowEnabled: false;
        }

        .shadowEnabled {
            dropShadowEnabled: true;
        }
    </mx:Style>

    <mx:Script>
        <![CDATA[
            private function checkBox_change(evt:Event):void {
                var value:String = "shadowEnabled";
                if (!checkBox.selected) {
                    value = "shadowDisabled;"
                }
                comboBox.setStyle("dropdownStyleName", value);
                comboBox.validateNow();
                comboBox.open();
            }
        ]]>
    </mx:Script>

    <mx:Array id="arr">
        <mx:Object label="One" />
        <mx:Object label="Two" />
        <mx:Object label="Three" />
    </mx:Array>

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

    <mx:ComboBox id="comboBox"
            dataProvider="{arr}"
            openDuration="0"
            closeDuration="0" />

</mx:Application>
 
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