码迷,mamicode.com
首页 > 其他好文 > 详细

[Flex] Accordion系列 - Header图标的设置

时间:2015-12-24 13:14:00      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

<?xml version="1.0" encoding="utf-8"?>
<!--Flex中如何通过getHeaderAt()函数以及selectedUpIcon,selectedOverIcon和selectedDownIcon样式给Accordion头部设置一个分割用图标的例子-->
<s:Application name="Accordion_getHeaderAt_selectedUpIcon_test"
               xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            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;

            protected function accordion_creationCompleteHandler(event:FlexEvent):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);
                }

            }
            
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    </fx:Declarations>
    <mx:Accordion id="accordion" openDuration="250" width="100%"  height="100%" creationComplete="accordion_creationCompleteHandler(event)">
        <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>
</s:Application>

 

[Flex] Accordion系列 - Header图标的设置

标签:

原文地址:http://www.cnblogs.com/frost-yen/p/5072594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!