• Follow us on Twitter
  • Join our Facebook Group
  • Join me on Google Plus
  • Add me on Linkedin
  • RSS
New prints available for sale! close

  • Home
  • Articles
    • Artistic Process
    • Software Engineering
      • Android
      • HTML5 & JavaScript
    • Reviews
    • Personal
    • Books
      • Technical
  • Portfolio
  • Store
    • Giclee Prints
    • Your Account
    • Transaction Results
    • Checkout
  • Bucket-List
  • Contact

Blog - Latest News

A Better Way to Skin the TabNavigator in Flex 3.5

1 Comment/ in Articles, Flash Platform, Software Engineering / by admin
April 27, 2011

… is to not use TabNavigator at all. Use a ViewStack and RadioButtons in an HBox!

I like doing skinning work in Flex but there certainly are a few components that I often times find easier to just re-engineer than skin. Scroll bars and TabNavigators are some examples of such components. I’ve heard skinning these components has gotten much easier in Flex 4, but alas, all my projects are still being developed in Flex 3.5.

I was recently given the task of skinning a ‘tabbed’ component, which was previously using the TabNavigator. In Flex 3.5, one can assign custom skins for the first, and last tabs, then a repeating skin for any in-between. This is a fairly common setup for tabs, but unfortunately in this particular component each tab needed to be unique. Another caveat of the component was that the tab bar needed to be wider than the views. After struggling once again to skin the TabNavigator to meet my needs, I finally decided that it might be easier to just do a little re-engineering.

In the past I’d done a series of normal Buttons in an HBox and scripted the ‘turn off/on’ for the other buttons. This time I decided to use RadioButtons and it went flawlessly! The script below shows how to do this. I believe this approach could be used in many situations and not require a lot of re-engineering since it can be done entirely in MXML. Another neat feature of this that the TabNavigator doesn’t allow is a ‘intro screen’ that doesn’t necessarily relate to the tabs, like the blank grey view in my example below.

Get Adobe Flash player

<!--?xml version="1.0" encoding="utf-8"?-->

		.characterName {
			fontSize: 24;
			fontWeight: bold;
			color: #FFFFFF;
		}

		.tab1 {
 			up-skin: Embed(source='/style/batman_d.jpg');
			down-skin: Embed(source='/style/batman_u.jpg');
			over-skin: Embed(source='/style/batman_u.jpg');

			selected-up-skin: Embed(source='/style/batman_u.jpg');
			selected-down-skin: Embed(source='/style/batman_u.jpg');
			selected-over-skin: Embed(source='/style/batman_u.jpg');

			upIcon: ClassReference("mx.skins.ProgrammaticSkin");
			overIcon: ClassReference("mx.skins.ProgrammaticSkin");
			downIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedUpIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedOverIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedDownIcon: ClassReference("mx.skins.ProgrammaticSkin");
			disabledIcon:ClassReference("mx.skins.ProgrammaticSkin");
			selectedDisabledIcon: ClassReference("mx.skins.ProgrammaticSkin");
		}

		.tab2 {
			up-skin: Embed(source='/style/wolverine_d.jpg');
			down-skin: Embed(source='/style/wolverine_u.jpg');
			over-skin: Embed(source='/style/wolverine_u.jpg');

			selected-up-skin: Embed(source='/style/wolverine_u.jpg');
			selected-down-skin: Embed(source='/style/wolverine_u.jpg');
			selected-over-skin: Embed(source='/style/wolverine_u.jpg');

			upIcon: ClassReference("mx.skins.ProgrammaticSkin");
			overIcon: ClassReference("mx.skins.ProgrammaticSkin");
			downIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedUpIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedOverIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedDownIcon: ClassReference("mx.skins.ProgrammaticSkin");
			disabledIcon:ClassReference("mx.skins.ProgrammaticSkin");
			selectedDisabledIcon: ClassReference("mx.skins.ProgrammaticSkin");
		}

		.tab3 {
			up-skin: Embed(source='/style/wonderwoman_d.jpg');
			down-skin: Embed(source='/style/wonderwoman_u.jpg');
			over-skin: Embed(source='/style/wonderwoman_u.jpg');

			selected-up-skin: Embed(source='/style/wonderwoman_u.jpg');
			selected-down-skin: Embed(source='/style/wonderwoman_u.jpg');
			selected-over-skin: Embed(source='/style/wonderwoman_u.jpg');

			upIcon: ClassReference("mx.skins.ProgrammaticSkin");
			overIcon: ClassReference("mx.skins.ProgrammaticSkin");
			downIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedUpIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedOverIcon: ClassReference("mx.skins.ProgrammaticSkin");
			selectedDownIcon: ClassReference("mx.skins.ProgrammaticSkin");
			disabledIcon:ClassReference("mx.skins.ProgrammaticSkin");
			selectedDisabledIcon: ClassReference("mx.skins.ProgrammaticSkin");
		}
← The Elephant (that was?) In The Room
Vacation At Club Med Turkoise →
Comments

One Response to A Better Way to Skin the TabNavigator in Flex 3.5

  1. Cédric says:
    August 9, 2011 at 5:02 pm

    Good tip !

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Posts

  • AngularJS: Building My Rotten App
  • JavaScript WebSpinners
  • JavaScript Scope & Closures
  • Introduction to JavaScript’s Prototype Inheritance
  • ADB Not Recognizing Devices on OSX – EasyTether problem

Recent Comments

  • Allison on Minneapolis Events and Adventures Sales Practices
  • Judy on JavaScript WebSpinners
  • MickeyD on Minneapolis Events and Adventures Sales Practices
  • MickeyD on Minneapolis Events and Adventures Sales Practices
  • Andy on Kindle PaperWhite & Whispersync for Voice – The perfect reader companion!

Archives

  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • October 2012
  • June 2012
  • May 2012
  • January 2012
  • October 2011
  • July 2011
  • April 2011
  • March 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • March 2010
  • February 2010
  • November 2009
  • August 2009
  • June 2009
  • February 2009
  • May 2008
  • April 2008
  • March 2008
  • December 2007
  • August 2007
  • July 2007
  • June 2007
  • April 2007
  • March 2007
  • February 2007

Categories

  • Android
  • Articles
  • Artistic Process
  • Design Patterns
  • e-Learning
  • Featured
  • Flash Platform
  • HTML5
  • JavaScript
  • Just For Fun
  • Personal
  • Reviews
  • Software Engineering
  • Speaking
  • User Experience Design

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
All images and content is copyrighted Daniel C. Holth unless otherwise noted. Please don't steal.
© Copyright - d.c.Holth - Wordpress Theme by Kriesi.at