Search This Blog

Monday, January 11, 2010

Flex accordion with multiple color tabs


I thought it would be good to start with sharing my recent research on coloring the Accordion tabs. Here is the MXML:


<mx:style>
AccordionHeader
{
fillAlphas: 1, 1;
cornerRadius: 4;
downSkin: ClassReference("mx.skins.halo.ButtonSkin");
overSkin: ClassReference("mx.skins.halo.ButtonSkin");
upSkin: ClassReference("mx.skins.halo.ButtonSkin");
selectedDownSkin: ClassReference("mx.skins.halo.ButtonSkin");
selectedOverSkin: ClassReference("mx.skins.halo.ButtonSkin");
selectedUpSkin: ClassReference("mx.skins.halo.ButtonSkin");
disabledSkin: ClassReference("mx.skins.halo.ButtonSkin");
selectedDisabledSkin: ClassReference("mx.skins.halo.ButtonSkin");
}
</mx:style>


<mx:accordion x="0" id="accMain" width="88%" height="88%" backgroundalpha="0" creationcomplete="accordionInit()"
rotation="0">
<mx:VBox label="Google Page Rank" width="100%" height="100%" backgroundAlpha="0" backgroundColor="#FFFFFF" paddingTop="10" paddingLeft="10">

<mx:HBox width="100%" >
<mx:Text text="URL:"/> <mx:TextInput id="urlbox" backgroundAlpha="0.1" width="345"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Button label="Get PR!" click="getPageRank();" />
</mx:HBox>
<mx:HBox width="100%" >
<mx:Text text="PageRank is:" id="result"/>
</mx:HBox>

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
<mx:VBox label="Other" width="100%" height="100%" backgroundColor="#FFFFFF">

</mx:VBox>
</mx:accordion>


Here is the actionscript:

private function accordionInit():void
{
accMain.getHeaderAt(0).setStyle("fillColors", ["#6E0404", "#6E0404"]);
accMain.getHeaderAt(0).setStyle("themeColor", "#6E0404");
accMain.getHeaderAt(0).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(1).setStyle("fillColors", ["#A30505", "#A30505"]);
accMain.getHeaderAt(1).setStyle("themeColor", "#A30505");
accMain.getHeaderAt(1).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(2).setStyle("fillColors", ["#E30707", "#E30707"]);
accMain.getHeaderAt(2).setStyle("themeColor", "#E30707");
accMain.getHeaderAt(2).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(3).setStyle("fillColors", ["#F93737", "#F93737"]);
accMain.getHeaderAt(3).setStyle("themeColor", "#F93737");
accMain.getHeaderAt(3).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(4).setStyle("fillColors", ["#FB6F6F", "#FB6F6F"]);
accMain.getHeaderAt(4).setStyle("themeColor", "#FB6F6F");
accMain.getHeaderAt(4).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(5).setStyle("fillColors", ["#FC9898", "#FC9898"]);
accMain.getHeaderAt(5).setStyle("themeColor", "#FC9898");
accMain.getHeaderAt(5).setStyle("color", "#FFFFFF");

accMain.getHeaderAt(6).setStyle("fillColors", ["#FDC9C9", "#FDC9C9"]);
accMain.getHeaderAt(6).setStyle("themeColor", "#FDC9C9");
accMain.getHeaderAt(6).setStyle("color", "#FFFFFF");
}


3 comments:

  1. Thanks for this superb solution ...

    ReplyDelete
  2. @namespace s "library://ns.adobe.com/flex/spark";
    @namespace mx "library://ns.adobe.com/flex/mx";
    .customAccordionHeadStyles1 {
    skin: ClassReference("HeaderSkin1");

    }
    .customAccordionHeadStyles2 {
    skin: ClassReference("HeaderSkin2");
    }
    .customAccordionHeadStyles3 {
    skin: ClassReference("HeaderSkin3");
    }

    ReplyDelete