Is there any way to vary a Flex 4 theme by color?
When I choose the default theme (Spark Default) in a Flex 4 app, I can merely change the chromeColor value and the theme will effectively change the base color of the theme for me.
A开发者_高级运维re there any special tricks to creating a new theme that uses this same concept? What if the new theme is a more graphical theme?
I'd like to offer a number of base themes for my application, each theme having it's own set of color variants.
If you're just looking for how to make themes you can easily google Flex Create Theme and you should get your answer. Honestly from having used a few different methods of getting "themes" in place I don't know that going through with making a swc based theme is necessary or worthwhile most of the time. Basically you're options are create multiple CSS files that you change out at compile time, if you want them to change at run-time you can compile the CSS into a SWF (in flash builder right click the css and compile to swf) then you can load these at runtime http://livedocs.adobe.com/flex/3/html/help.html?content=styles_10.html I personally do more component development and less styling but from the people I work with whose primary occupation is styling I've heard great things about using SASS (google it, basically takes some programmatic style css and makes one css file for you but can do all sorts of cool stuff) to keep this all organized and easy to update. You might also want to check out this relative location on your file system to see what they've done to make the halo theme's and stuff:
\Program Files\Adobe\Flex Builder 3 Plug-in\sdks\3.4\frameworks\themes (SDK version will vary based on what you downloaded or installed)
The trick is to make sure your custom skins are extended from SparkSkin rather than just the Skin class. SparkSkin has logic that applies the chromeColor to all of the elements of the skin (except for those returned in your overridden "colorizeExclusions" getter) by applying a color transform. Take a look at the default ButtonSkin for a typical example of how to create a component skin that takes advantage of the SparkSkin chromeColor behavior.
Regarding using graphical elements in your skin, just make sure they are greyscale and the chromeColor will get applied just fine.
Hope that helps.
精彩评论