<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <!--[CDATA[ import mx.containers.VBox; import mx.controls.Alert; import mx.events.IndexChangedEvent; private function init():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"); } private function click(event:IndexChangedEvent):void{ var ad:Accordion = event.currentTarget as Accordion; //两种方法 //第一种获得index var index:int = event.newIndex; var box1:VBox = ad.getChildAt(index) as VBox; Alert.show(box1.label.toString()); //第二种 //var box2:VBox = ad.selectedChild as VBox; //Alert.show(box2.label); } ]]--> </mx:Script> <mx:Accordion id="accordion" width="300" height="200" creationComplete="init();" change="{click(event);}"> <mx:VBox label="Red" /> <mx:VBox label="Orange" /> <mx:VBox label="Yellow" /> <mx:VBox label="Green" /> <mx:VBox label="Blue" /> </mx:Accordion> </mx:Application>
flex里面Accordion的用法
最新推荐文章于 2014-12-09 12:24:17 发布