<?xml version="1.0" encoding="utf-8"?> <!--Flex中如何给Accordion的各个头部文字设置不同颜色的例子--> <s:Application 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; protected function accordion_creationCompleteHandler(event:FlexEvent):void { accordion.getHeaderAt(0).setStyle("color", "red"); accordion.getHeaderAt(1).setStyle("color", "haloOrange"); accordion.getHeaderAt(2).setStyle("color", "yellow"); accordion.getHeaderAt(3).setStyle("color", "haloGreen"); accordion.getHeaderAt(4).setStyle("color", "haloBlue"); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; mx|Accordion { headerStyleName:accheader; } .accheader{ fillColors:haloSilver, haloBlue; fillAlphas:1,0.5; selectionColor:black; textRollOverColor:white; textSelectedColor:white; chromeColor:black; } </fx:Style> <mx:Accordion id="accordion" openDuration="250" width="300" height="200" creationComplete="accordion_creationCompleteHandler(event)"> <mx:VBox label="Red" /> <mx:VBox label="Orange" /> <mx:VBox label="Yellow" /> <mx:VBox label="Green" /> <mx:VBox label="Blue" /> </mx:Accordion> </s:Application>
时间: 2024-12-09 23:30:20