{"id":26,"date":"2007-01-27T20:13:33","date_gmt":"2007-01-28T04:13:33","guid":{"rendered":"http:\/\/dougmccune.com\/blog\/2007\/01\/27\/horizontal-accordion-component-for-flex\/"},"modified":"2007-01-27T20:14:07","modified_gmt":"2007-01-28T04:14:07","slug":"horizontal-accordion-component-for-flex","status":"publish","type":"post","link":"https:\/\/dougmccune.com\/blog\/2007\/01\/27\/horizontal-accordion-component-for-flex\/","title":{"rendered":"Horizontal Accordion Component for Flex"},"content":{"rendered":"<p>People have asked for an Accordion component that lays itself out horizontally instead of vertically. Looks like Scott Barnes had <a href=\"http:\/\/www.mossyblog.com\/archives\/485.cfm\">put one together<\/a> back in 2005 that worked for Flex 1.5. Seeing as he&#8217;s now as Microsoft I&#8217;d say the chances of him porting it to Flex 2 are zip. Others <a href=\"http:\/\/viconflex.blogspot.com\/2006\/11\/deal-with-embedded-fonts-buttons-and.html\">seem to be trying<\/a> to make this component as well. Well, here it is, an accordion component that cascades horizontally for Flex 2. <\/p>\n<p>You use it just like the normal accordion component. The only difference is now you can use the &#8220;headerWidth&#8221; style instead of headerHeight to set the width of the tabs in CSS. <\/p>\n<p>Making the component wasn&#8217;t that difficult, but it required a complete copy\/paste of the Accordion component. If you look at the source you&#8217;ll see that I&#8217;ve made a class called AccordionBase. Basically this base class is a straight copy of the Accordion class from the framework but modified to allow it to be extended easier. That means I changed a bunch of properties and methods that were private to protected, so my subclasses could access them. Once I made these changes the only other thing I did to AccordionBase was remove the updateDisplayList and measure methods. These methods are defined in the subclasses, which are HAccordion and VAccordion. Each of those subclasses has slightly different code to do the layout and tweening. Ideally I would have been able to do this without making a new AccordionBase class that duplicated the code of Accordion, but this is another instance where a simple extension of a class doesn&#8217;t give you enough access to the parent class.<\/p>\n<p>The one important thing to be aware of is that you MUST embed the font that you&#8217;ll be using for the text of the HAccordion&#8217;s headers. The component rotates the headers by 90 degrees, and if you rotate a text component then it will only work if you have the font embedded. See the source of the example MXML file to see how I did this, it&#8217;s simple, but if you don&#8217;t do it you&#8217;ll be wondering why the headers are all blank.<\/p>\n<p>I packaged the component as a SWC. You can download the SWC and drop it into a Flex project. <a href=\"http:\/\/dougmccune.com\/flex\/haccordion\/HAccordion.swc\">Download the SWC here<\/a>. (281 K)<\/p>\n<p>Here&#8217;s the <a href=\"http:\/\/dougmccune.com\/flex\/haccordion\/srcview\/index.html\">full source<\/a> of the component. And here&#8217;s the <a href=\"http:\/\/dougmccune.com\/flex\/haccordion_test\/srcview\/index.html\">source of the example MXML<\/a> file that makes the example below.<\/p>\n<p><div id=\"swf87bf1\">This movie requires Flash Player 9.<\/div>\n<script type=\"text\/javascript\">\n\tswfobject.embedSWF(\"\/flex\/haccordion_test\/HAccordion_Test.swf\", \"swf87bf1\", \"400\", \"550\", \"9.0.0\", \"\", {}, {wmode: \"window\", menu: \"false\", quality: \"high\", bgcolor: \"#FFFFFF\", allowScriptAccess: \"always\"}, {});\n<\/script>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>People have asked for an Accordion component that lays itself out horizontally instead of vertically. Looks like Scott Barnes had put one together back in 2005 that worked for Flex 1.5. Seeing as he&#8217;s now as Microsoft I&#8217;d say the chances of him porting it to Flex 2 are zip. Others seem to be trying [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-flex"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":0,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dougmccune.com\/blog\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}