tags:

views:

85

answers:

3

I have a component based on HBox that has multiple labels in it. I want to be able to set all the style properties, things like fontSize, fontWeight, color, etc. on my component and have them applied to all the Labels contained by it. Whats the best approach for this? I tried to have my component implement Label but there is no Label interface.

Thanks.

P.S. Wasn't sure what would be a good title for this question so feel free to edit it if you have something better.

A: 

Two options I can think of:

  1. You could provide a default stylesheet (default.css) with your component and have use custom styles for Label.fontSize, Label.fontWeight, etc which would propagate throughout.
  2. You could extend Label to create a custom component and define default styles within that. Then use your custom Label within your custom component.

Check out this documentation for more info:
http://livedocs.adobe.com/flex/3/html/help.html?content=ascomponents_8.html

Stiggler
A: 

I didn't realize this but you can already just set all those properties on the HBox and the labels inside it inherit them. :)

John Isaacks
A: 

I answered a similar question a while back:

http://stackoverflow.com/questions/724054/how-to-manage-styles-for-child-components/725971#725971

Eric Belair