小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

格式化ComboBox控件的滚动条提示内容.

ComboBox控件的dropdown属性中的scrollTipFunction属性.
示例:

代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/01/formatting-scroll-tips-on-a-combobox-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="top"
        backgroundColor
="white">

    
<mx:Script>
        
<![CDATA[
            import mx.events.DropdownEvent;

            private function comboBox_open(evt:DropdownEvent):void {
                comboBox.dropdown.showScrollTips = checkBox.selected;
                comboBox.dropdown.scrollTipFunction = comboBox_dropdown_scrollTipFunc;
            }

            private function comboBox_dropdown_scrollTipFunc(dir:String, pos:uint):String {
                return pos + " of " + comboBox.dropdown.maxVerticalScrollPosition;
            }
        
]]>
    
</mx:Script>

    
<mx:Array id="arr">
        
<mx:Object label="One" />
        
<mx:Object label="Two" />
        
<mx:Object label="Three" />
        
<mx:Object label="Four" />
        
<mx:Object label="Five" />
        
<mx:Object label="Six" />
        
<mx:Object label="Seven" />
        
<mx:Object label="Eight" />
        
<mx:Object label="Nine" />
        
<mx:Object label="Ten" />
    
</mx:Array>

    
<mx:ApplicationControlBar dock="true">
        
<mx:Form styleName="plain">
            
<mx:FormItem label="showScrollTips:">
                
<mx:CheckBox id="checkBox"
                        selected
="true" />
            
</mx:FormItem>
        
</mx:Form>
    
</mx:ApplicationControlBar>

    
<mx:ComboBox id="comboBox"
            dataProvider
="{arr}"
            open
="comboBox_open(event);" />

</mx:Application>

posted on 2008-07-14 15:10  『小小菜鸟』  阅读(616)  评论(0编辑  收藏  举报