View Full Version : The StyleName Property
YAOMK
11-15-2008, 01:55 PM
Alright, this it my first post/question about Flex:
What is the purpose of setting the styleName property of a component inside a custom MXML component to the same name of the custom component?
<mx:canvas styleName="nameOfComponent" etc...>
I'm guessing it it to flush default styles, but I'm not 100% sure. Thanks.
fx.barrett
11-15-2008, 02:17 PM
Quoted from the Flex 3 Help file:
The class style used by this component. This can be a String, CSSStyleDeclaration or an IStyleClient.
If this is a String, it is the name of a class declaration in an mx:Style tag or CSS file. You do not include the period in the styleName. For example, if you have a class style named ".bigText", set the styleName property to "bigText" (no period).
If this is an IStyleClient (typically a UIComponent), all styles in the styleName object are used by this component.
The default value is null.
It is used to associated certain styles with certain components. If that certain style is applied to only 1 component than it would be normal to name it as the component to avoid confusion ( it would be cofusing if a component is named ContactForm and it's style name is "blackDog"... ok, the example might not be bright, but I hope you got the idea ). In case the style is applied to more than 1 component ( which doesn't happen too often ) than you should give it a more generalized name like "menuBarStyles" or something like that.
YAOMK
11-15-2008, 02:40 PM
Thanks fx.barrett, something tells me I'll be hearing more from you...
I looked at documentation under "canvas" but styleName was not even listed as a property there ... I guess I should have looked a bit harder. I'm following a MVCS example from the Adobe Developer Center. I been trying to figureout how to apply the OOP principles in Flex and that little detail is thrown me off for a couple hours. Thanks a lot for your help and your rather clear example.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.