Flex中如何通过getHeaderAt()函数以及selectedUpIcon,selectedOverIcon和selectedDownIcon样式给Accordion头部设置一个分割用图标的例子

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" name="Accordion_getHeaderAt_selectedUpIcon_test" >
        <mx:Style>
         AccordionHeader{
         fillColors:black,gay;
         fillAlphas: 1, 1;
         textRollOverColor: white;
            textSelectedColor: white;
            themeColor: black;
             }
        </mx:Style>
    <mx:Script>
        <![CDATA[
            import mx.controls.Button;
            [Embed("assets/1.png")]
            private const RedIcon:Class;
 
            [Embed("assets/2.png")]
            private const OrangeIcon:Class;
 
            [Embed("assets/3.png")]
            private const YellowIcon:Class;
 
            [Embed("assets/00972.png")]
            private const GreenIcon:Class;
 
            [Embed("assets/01263.png")]
            private const BlueIcon:Class;
 
            [Embed("assets/02169.png")]
            private const StarIcon:Class;
 
            private function init():void {
                var idx:uint;
                var len:uint = accordion.numChildren;
                var btn:Button;
                for (idx=0; idx<len; idx++) {
                    btn = accordion.getHeaderAt(idx);
                    btn.useHandCursor = true;
                    btn.buttonMode = true;
                    btn.setStyle("selectedUpIcon", StarIcon);
                    btn.setStyle("selectedOverIcon", StarIcon);
                    btn.setStyle("selectedDownIcon", StarIcon);
                }
                accordion.getHeaderAt(0).setStyle("color","red");
                accordion.getHeaderAt(1).setStyle("color","halogreen");
                accordion.getHeaderAt(2).setStyle("color","yellow");
                accordion.getHeaderAt(3).setStyle("color","haloblue");
                accordion.getHeaderAt(4).setStyle("color","haloOrange");           }
        ]]>
    </mx:Script>
 
    <mx:Accordion id="accordion"
            openDuration="0"
            width="100%"
            height="100%"
            creationComplete="init();">
        <mx:VBox id="redVbox"
                label="Red"
                icon="{RedIcon}" />
        <mx:VBox id="orangeVbox"
                label="Orange"
                icon="{OrangeIcon}" />
        <mx:VBox id="yellowVbox"
                label="Yellow"
                icon="{YellowIcon}" />
        <mx:VBox id="greenVbox"
                label="Green"
                icon="{GreenIcon}" />
        <mx:VBox id="blueVbox"
                label="Blue"
                icon="{BlueIcon}" />
    </mx:Accordion>
</mx:Application>

你可能感兴趣的:(Flex中如何通过getHeaderAt()函数以及selectedUpIcon,selectedOverIcon和selectedDownIcon样式给Accordion头部设置一个分割用图标的例子)