<?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; CSS</title>
	<atom:link href="http://blog.smartlogicsolutions.com/tag/css/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>
		<item>
		<title>Advanced CSS in Flex 4 &#8211; ID and Descendant Selectors</title>
		<link>http://blog.smartlogicsolutions.com/2008/10/21/advanced-css-in-flex-4-id-and-descendant-selectors/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/10/21/advanced-css-in-flex-4-id-and-descendant-selectors/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 00:39:41 +0000</pubDate>
		<dc:creator>Greg Jastrab</dc:creator>
				<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Greg Jastrab]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=338</guid>
		<description><![CDATA[NOTE: View my comment below for updated code on making this work with the latest SDK (as of 5/25/09). A few days ago one of the commit messages in the Gumbo trunk mentioned some work for advanced CSS was beginning. I tried to create an example of using a descendant selector as well as an [...]]]></description>
			<content:encoded><![CDATA[<p><b>NOTE:</b> View <a href="http://blog.smartlogicsolutions.com/2008/10/21/advanced-css-in-flex-4-id-and-descendant-selectors/comment-page-1/#comment-2423">my comment below</a> for updated code on making this work with the latest SDK (as of 5/25/09).</p>
<p>A few days ago one of the commit messages in the <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk">Gumbo trunk</a> mentioned some work for advanced CSS was beginning.  I tried to create an example of using a descendant selector as well as an ID selector, but neither worked.</p>
<p>Tonight, another commit message said that this was now in place by default (I guess it would have worked earlier, but I needed to be specify a compiler argument).  But now, after rebuilding the latest checkout of <a href="http://opensource.adobe.com/wiki/display/flexsdk/Gumbo">Gumbo</a> you should now be able to compile the following example to see the advanced CSS selectors working.  Below is the SWF (you&#8217;ll need <a href="http://www.adobe.com/go/getflash">Flash Player 10</a> to view it) and the code follows:</p>
<p><span id="more-338"></span></p>
<p>[flash http://blog.smartlogicsolutions.com/wp-content/uploads/2008/10/CSSExample.swf]</p>
<h4>CSSExample.mxml</h4>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;FxApplication</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;VerticalLayout</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Style</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;descendants.css&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;VGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Text in a VGroup<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/VGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;HGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;red&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Text in an HGroup<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/HGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/FxApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Standard so far, now let&#8217;s see the CSS with the advanced selectors:</p>
<h4>descendants.css</h4>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">VGroup TextView <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">24pt</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
HGroup TextView <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#red</span> <span style="color: #00AA00;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ff0000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Flex 4 is now fully demonstrating the <b>Cascading</b> part of CSS.  (You may need to review <a href="http://www.w3.org/TR/CSS21/selector.html">CSS selectors syntax</a>.)  <b>NOTE:</b> I don&#8217;t know how much of the CSS spec is going to be supported in Flex 4, and am not suggesting that everyone of the selectors at the CSS selectors page will be available in Flex 4.</p>
<p>The <code>VGroup TextView</code> selector targets any TextView instances which are a child of a VGroup.  <code>#red</code> selector targets instances with an ID of &#8220;red&#8221;.</p>
<p>As usual, here is the <a href="http://blog.smartlogicsolutions.com/wp-content/uploads/2008/10/cssexample.tgz">bundled source and SWF</a>.</p>
<p>I hope everyone’s enjoying their Gumbo!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2008/10/08/new-flex-4-theme-and-class-renaming/" rel="bookmark" class="crp_title">New Flex 4 Theme and Class Renaming</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/09/25/rotate-effect-and-non-embedded-fonts-in-flex-4/" rel="bookmark" class="crp_title">Rotate Effect and Non Embedded Fonts in Flex 4</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/05/06/flex4-opensource-gumbo-planning-documents/" rel="bookmark" class="crp_title">Flex 4 &#8220;Gumbo&#8221; Planning Documents</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/15/compiling-your-first-flex-4-application/" rel="bookmark" class="crp_title">Compiling Your First Flex 4 Application</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/10/21/advanced-css-in-flex-4-id-and-descendant-selectors/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

