OK, I admit that this post probably doesn’t have much real-world use, and can probably annoy users if implemented poorly, but if you’ve ever wondered how/if you can change the opening/closing duration or easing function used for a ComboBox dropdown menu, this post is for you!
This entry looks at customizing the ComboBox control’s openDuration and closeDuration styles which control how long it takes for the dropdown menu to appear or disappear. By default both of these styles are set to 250 milliseconds (1/4 second). We’ll also look at changing the easing method used to animate the dropdown menu. Finally, we look at explicitly setting the dropdown menu’s width so it doesn’t inherit the ComboBox’s width and alternate the row colors for the items in the dropdown.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/18/changing-the-flex-combobox-controls-opening-and-closing-easing-functions/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.effects.easing.*;
]]>
</mx:Script>
<mx:ComboBox id="comboBox"
openDuration="1000"
openEasingFunction="Bounce.easeOut"
closeDuration="1000"
closeEasingFunction="Bounce.easeIn"
prompt="Please select an item..."
selectedIndex="-1"
dropdownWidth="150"
alternatingItemColors="[0xDFDFDF, 0xEEEEEE]">
<mx:dataProvider>
<mx:Array>
<mx:Object label="Item 1" />
<mx:Object label="Item 2" />
<mx:Object label="Item 3" />
<mx:Object label="Item 4" />
<mx:Object label="Item 5" />
<mx:Object label="Item 6" />
<mx:Object label="Item 7" />
<mx:Object label="Item 8" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:Application>
View source is enabled in the following example.





0 Responses to “Changing the Flex ComboBox control's opening and closing easing functions”
Leave a Reply