|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
TOP COLDFUSION LINKS CF & Flex Adobe Flex Interface Customization - Themes, Styles, Skins
The basics of themes, styles, and skins
By: Tariq Ahmed
Jun. 12, 2007 11:15 AM
One thing you may have noticed when I introduced the out-of-the-box themes - a bunch of them were CSS files. Which begs the question: Can you source them in using the <mx:Style> tag? Yup! As mentioned before, style definitions are the root of your theme. Just something to remember, though, is that you can't use the <mx:Style> to source in a theme SWC file; and using the -theme compiler option gives you extended flexibility to control what theme files to use during the build and release phase of the project (particularly useful for large projects). Flex gives you many deployment options here so use whatever's most convenient. The Skinny on Skins There's actually two ways to skin. Graphical skinning uses images to define parts or all of a component, and programmatic skinning lets you use code to define the way a component looks and behaves. Here we're going to look at the graphical way of using JPEGs, GIFs, and PNGs to define the look of a component. When skinning you take into consideration the states of a component or control; the common states that most controls exhibit are the mouse off, mouse over, and mouse down states. One of the most popular things in HTML to represent graphically is the button, and to add some pizzazz you could use some JavaScript to add a rollover effect that swapped out the default image to a mouse over state image. It's very simple in Flex; you use CSS/Styles to specify what assets to use for your graphical skins. In the Button Class (mx.controls.Button) documentation you'll notice it supports many Style properties, but namely the following skin-related properties:
If you want to take it a bit further you can also create images for the disabled state (i.e., <mx:Button enabled="false"/>), as well for the selected skins that are used to skin the background and the border of the button. To test them quickly, use the inline approach: <mx:Button label="My Skinned Button" Compile and run your application and you should see a button that changes when you mouse over it and click down on it. If your button is big enough to contain the text it will retain its original size, but if it wasn't Flex will automatically scale it to a big enough size. Add a fontSize="25" to your Button tag and see how Flex scales it: The whole Embed business is a directive that tells Flex to import the image during compile time. You can abstract the name of the actual image files out of the Button into a script area of your MXML and embed the image elsewhere so that your Button doesn't need to know the exact filenames involved by doing: <mx:Script> Of course even better is just wrapping that all up into a Style: <mx:Style> CFDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||