tags:

views:

32

answers:

1

I have a ButtonBar w/ a series of buttons that will each have a custom label:

  1. Person's name (fontsize 18)
  2. Person's address (fontsize 12)

I am using Flex 4 w/ a custom-skinned spark buttonbar.

I've got the following but how do I now change the fontsizes? Do I change this label function or is that somehow controlled in the spark skin?

'

  protected function customLabel(item:Object):String {
    return item.name+ "\n" + item.address;
}

'

A: 

A labelFunction's purpose is to return a string that can be used by the component as a display string for the item in question. labelFunction has no relation to how the data is displayed.

I did not believe any Flex Components support different fontsizes. I would look into creating your own custom component that uses two separate labels; one for each font size. You can probably extend the Button class easy enough to make this happen, adding a new skin part and create a custom skin class that deal with the font sizes and positioning.

www.Flextras.com
I've already created a custom skin, just have no idea how I'd do as you suggest in order to get the label the way I want.
ginius
I don't think that only a custom skin is going to do it. You also need a custom button so that you can have two different labels. Conceptually, extend the Button Class; add a new skinPart, create a custom skin for that class. Point the ButtonBar button factory's at your new button class. http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/spark/components/ButtonBar.html#top
www.Flextras.com
sounds too complicated. I might revisit this part of my app later when I have time...for now, I'm just gonna move on w/ what I have.
ginius
I wouldn't call it trivial, but the complication level depends how familiar you are with the Flex Component LifeCycle and building Spark component. I would recommend that any Flex Developer learn the component lifecycle by heart.
www.Flextras.com