Flex set icon on Accordion by setting getHeaderAt()

Flex set icon on Accordion by setting getHeaderAt()

Postby haretu » Thu Mar 24, 2011 10:47 am

Flex set icon on Accordion by setting getHeaderAt() function, selectedUpIcon,selectedOverIcon and selectedDownIcon

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Accordion_getHeaderAt_selectedUpIcon_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">

    <mx:Script>
        <![CDATA[
            import mx.controls.Button;

            [Embed("assets/bullet_red.png")]
            private const RedIcon:Class;

            [Embed("assets/bullet_orange.png")]
            private const OrangeIcon:Class;

            [Embed("assets/bullet_yellow.png")]
            private const YellowIcon:Class;

            [Embed("assets/bullet_green.png")]
            private const GreenIcon:Class;

            [Embed("assets/bullet_blue.png")]
            private const BlueIcon:Class;

            [Embed("assets/bullet_star.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);
                }
            }
        ]]>
    </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>
Attachments
Screen shot 2011-03-24 at 10.47.06 AM.png
Screen shot 2011-03-24 at 10.47.06 AM.png (15.04 KiB) Viewed 852 times
haretu
 
Posts: 132
Joined: Sat Jan 08, 2011 9:56 pm

Return to Adobe FLEX Flash

Who is online

Users browsing this forum: No registered users and 1 guest

cron