• 最简单的方法改变combobox的样式 - [flash学习笔记]2009-09-16

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://crazyrabbit.blogbus.com/logs/46614588.html

    两个类文件CustomCellRenderer.as 和CustomComboBox.as

    package com.rockabit.utils.as3
    {
        import fl.controls.listClasses.CellRenderer;
       
        import flash.text.TextFormat;
       
        /**
        * Custom cellRenderer for comboBox list items.
        */
        public class CustomCellRenderer extends CellRenderer
        {
           
            public function CustomCellRenderer()
            {
                super();
                this.setStyle('embedFonts', true);
                this.setStyle('textFormat', new TextFormat(new tahoma().fontName, 14, 0x000000));
            }
           
        }
       
    }

    类文件2

    package com.rockabit.utils.as3
    {
        import fl.controls.ComboBox;
        import fl.controls.List;
       
        import flash.text.TextFormat;
       
        /**
        * Customized ComboBox component. Graphic changes have been made inside the component itself,
        * in the library, changes in textual display are made here.
        */
        public class CustomComboBox extends ComboBox
        {
            private var textFormat:TextFormat;
           
            public function CustomComboBox()
            {
                super();
               
                textFormat = new TextFormat(new tahoma().fontName, 11, 0x000000);
               
                //textField is the top text, in the closed combobox
                textField.setStyle('embedFonts', true);
                textField.setStyle('textFormat', textFormat);
               
                //dropdown is the list that shows when you open the combobox
                dropdown.setStyle('cellRenderer', CustomCellRenderer);
            }
        }
    }

    这个类文件扩展combobox,

    拖一个combobox到库中,然后,右键属性把类改成CustomComboBox,只是要注意路径要正确


    收藏到:Del.icio.us