<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SmartLogic Solutions Blog &#187; design</title>
	<atom:link href="http://blog.smartlogicsolutions.com/tag/design/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Flex 3: Styling Individual Tabs in a TabBar</title>
		<link>http://blog.smartlogicsolutions.com/2008/11/10/flex-3-styling-individual-tabs-in-a-tabbar/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/11/10/flex-3-styling-individual-tabs-in-a-tabbar/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 15:36:54 +0000</pubDate>
		<dc:creator>Glenn Gentzke</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Glenn Gentzke]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flex 2]]></category>
		<category><![CDATA[flex 3]]></category>
		<category><![CDATA[tab]]></category>
		<category><![CDATA[tabBar]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=357</guid>
		<description><![CDATA[There are a few ways to style the tabs in a TabBar that are fairly well hidden. Here are a couple methods that hopefully save some time for those of you out there looking to apply advanced styles tabs in Flex. If you need to style the tabs uniformly, then you&#8217;ve got little work to [...]]]></description>
			<content:encoded><![CDATA[<p>There are a few ways to style the tabs in a TabBar that are fairly well hidden.  Here are a couple methods that hopefully save some time for those of you out there looking to apply advanced styles tabs in Flex.</p>
<p>If you need to style the tabs uniformly, then you&#8217;ve got little work to do.  Just set the <strong>StyleName</strong> attribute on the TabBar itself and just define it in your stylesheet.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TabBar</span> id=<span style="color: #ff0000;">&quot;tabBar&quot;</span> styleName=<span style="color: #ff0000;">&quot;myTabBarStyle&quot;</span>  <span style="color: #7400FF;">/&gt;</span></span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.myTabBarStyle</span> <span style="color: #00AA00;">&#123;</span>
	tabHeight<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">28</span><span style="color: #00AA00;">;</span>
	cornerRadius<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	horizontalGap<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	horizontalAlign<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	backgroundAlpha<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
	backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#357cc6</span><span style="color: #00AA00;">;</span>
	borderStyle<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	borderThickness<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	dropShadowEnabled<span style="color: #00AA00;">:</span> false<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now that&#8217;s all good and well when all your tabs look the same.  What if you want to apply styles to tabs individually?  Well, if you&#8217;ve got 3 tabs or less you can use some css selectors to reference the book ends specifically, and let the general style apply to the middle tab.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.myTabBarStyle<span style="color: #00AA00;">&#123;</span>
    ...
  tabStyleName<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;greenTab&quot;</span><span style="color: #00AA00;">;</span>
  firstTabStyleName<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;blueTab&quot;</span><span style="color: #00AA00;">;</span>
  lastTabStyleName<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;yellowTab&quot;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.greenTab</span> <span style="color: #00AA00;">&#123;</span>
  fillColors<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#a5d414</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#87c408</span><span style="color: #00AA00;">;</span>
  backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#87c408</span><span style="color: #00AA00;">;</span>
   borderColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#87c408</span><span style="color: #00AA00;">;</span>
  themeColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#a5d414</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.blueTab</span> <span style="color: #00AA00;">&#123;</span>
  fillColors<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#5a9cd6</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#357cc6</span><span style="color: #00AA00;">;</span>
  backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#357cc6</span><span style="color: #00AA00;">;</span>
  borderColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#357cc6</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span>
  textRollOverColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span>
  themeColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#5a9cd6</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yellowTab</span> <span style="color: #00AA00;">&#123;</span>
  fillColors<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span>
  backgroundColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span>
  borderColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#646464</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F8ED6D</span><span style="color: #00AA00;">;</span>
  textRollOverColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F8ED6D</span><span style="color: #00AA00;">;</span>
  themeColor<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#646464</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>When you have 4 or more tags, you need to set their styles by getting a reference to the tab <em>itself</em> and call the <strong>setStyle()</strong> method.  Straight forward? Yes. Easy to find information about? No&#8230; in fact I ran into trouble because there wasn&#8217;t any documentation available for an individual tab&#8217;s class and FlexBuilder 3 has no source code for the mx.controls.tabBarClasses package.</p>
<p>Import the Tab code, get a reference to the tab you wish to style, and call setStyle() for each attribute you want to change. Let&#8217;s say you have 4 tabs and each has a different style.  You can combine all 3 methods of styling by using the css code above to set the tab style for all tabs in the tabBar, override styles for the first and last tabs, then specifically grab the 3rd tab and override its style in the component:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">  <span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
    <span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">tabBarClasses</span>.<span style="color: #0066CC;">Tab</span>
&nbsp;
       <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> tabBarCreationComplete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
	  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">tab</span>:<span style="color: #0066CC;">Tab</span> = tabBar.<span style="color: #006600;">getChildAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Tab</span>;			  
	  <span style="color: #0066CC;">tab</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;fillColors&quot;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;#edb000&quot;</span>, <span style="color: #ff0000;">&quot;#e69500&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
          <span style="color: #0066CC;">tab</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;backgroundColor&quot;</span>, <span style="color: #ff0000;">&quot;#e69500&quot;</span><span style="color: #66cc66;">&#41;</span>;
          <span style="color: #0066CC;">tab</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;borderColor&quot;</span>, <span style="color: #ff0000;">&quot;#e69500&quot;</span><span style="color: #66cc66;">&#41;</span>;
          <span style="color: #0066CC;">tab</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;themeColor&quot;</span>, <span style="color: #ff0000;">&quot;#edb000&quot;</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
  <span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>And update the TabBar control:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;">  <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TabBar</span> id=<span style="color: #ff0000;">&quot;tabBar&quot;</span> </span>
<span style="color: #000000;">                     styleName=<span style="color: #ff0000;">&quot;myTabBarStyle&quot;</span></span>
<span style="color: #000000;">                     creationComplete=<span style="color: #ff0000;">&quot;tabBarCreationComplete();&quot;</span>  <span style="color: #7400FF;">/&gt;</span></span></pre></div></div>

<p>You can iterate through each tab in the TabBar and set each tab individually if desired.  I hope this helps some Flex developers out there who are confused by styling many tabs individually!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/" rel="bookmark" class="crp_title">Using Byobu and Landscape to improve remote Ubuntu sessions</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/16/skinning-button-flex-4-fxg/" rel="bookmark" class="crp_title">Skinning A Button in Flex 4 Using FXG</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/10/21/advanced-css-in-flex-4-id-and-descendant-selectors/" rel="bookmark" class="crp_title">Advanced CSS in Flex 4 &#8211; ID and Descendant Selectors</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/19/creating-custom-flex-4-skinnable-component/" rel="bookmark" class="crp_title">Creating Your First Custom SkinnableComponent in Flex 4</a></li><li><a href="http://blog.smartlogicsolutions.com/2007/06/06/eclipse-32-and-out-of-memory-errors/" rel="bookmark" class="crp_title">Eclipse 3.2 and &#8220;Out Of Memory&#8221; errors</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2008/11/10/flex-3-styling-individual-tabs-in-a-tabbar/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

