Flex Accordion headerRenderer实现child收缩

用Accordion组件的时候发现,child展开之后再点击的时候没有相应.
然后习惯性的Google发现解决方法大致是自定义一个组件...
感觉为了一个小功能重写有点 杀鸡用牛刀的感觉.
于是仔细想了下,发现其实只需要指定header的itemRenderer即可:
上代码 headerRenderer="com.MyAccHeader"
MyAccHeader:
package com
{
import flash.events.MouseEvent;
import mx.controls.Alert;
import mx.containers.Accordion;
import mx.containers.accordionClasses.AccordionHeader;
public class MyAccHeader extends AccordionHeader
{
public function MyAccHeader()
{
super();
this.addEventListener(MouseEvent.CLICK,fun);
}
private function fun(evt:MouseEvent):void
{
(this.parent as Accordion).selectedIndex = (this.parent as Accordion).selectedIndex+1;
}
}
}

你可能感兴趣的:(Flex,Google,Flash)