3

Hello all i have the code below to define a buttonbar control in spark:

<s:ButtonBar id="tabs" y="15" left="0" height="31" change="VideosMenuBar_changeHandler(event)">  
        <s:ArrayCollection>
            <fx:String>Latest Videos</fx:String>
            <fx:String>Last Week Videos</fx:String>
            <fx:String>Last Month Videos</fx:String>
        </s:ArrayCollection>
</s:ButtonBar>

and i have a few questions about it:

1) how can i make this buttonbar react like an mx ToggleButtonBar that is when i press a button twice not to lose its state but maintain it and change only if i press another button?

2)How to define the default pressed button?

3)and lastly, i have applied a ready made skin of flex in my application and this has given my buttons some properties on hover,selected etc., how can i define my own via a new skin on my buttons?can i define new properties for my buttonbar so as not to be affected by the owns declared in the skin or do i have to change something in that skin and how can this be done?

Thanks a lot beforehand for your help!

zero323
  • 322,348
  • 103
  • 959
  • 935
sstauross
  • 2,602
  • 2
  • 30
  • 50

1 Answers1

4
  1. Indeed. requireSelection="true"
  2. ButtonBar extends List so setting the selectedIndex property should work
  3. I'm not really sure what you mean, but you can change the skins of the buttons in your button bar using css:

    s|ButtonBarButton { skin-class: ClassReference("my.skin.class"); }

Or you can choose a custom button implementation by creating your own ButtonBarSkin to refer to your buttons.

<fx:Declarations>
    <fx:Component id="firstButton">
        <you:MyLastButton />
    </fx:Component>

    <fx:Component id="middleButton" >
        <you:MyLastButton />
    </fx:Component>

    <fx:Component id="lastButton" >
        <you:MyLastButton />
    </fx:Component>
</fx:Declarations>

Take a look at Spark's own ButtonBarSkin for a good example and make sure these buttons at least implement IItemRenderer or just extend ButtonBarButton

Treur
  • 763
  • 4
  • 13
  • Thanks a lot for your answer! what i mean about the third is: I have applied a theme in my application which has given its own characteristics in many components like how buttons,lists, buttonbar etc looks and my question is can i add my own characteristics on some components like buttons or buttonbarButton despite that the theme is still set in my app via css or create my own styl? will it apply on these components or should i disable the theme? – sstauross Feb 08 '12 at 14:32
  • A skin set on a Spark Button (set in your main css file?) shouldn't effect the buttons in the ButtonBar, because these are ToggleButtons and they require a separate skin. Besides, the skins for these ButtonBar buttons are set in the ButtonBarSkin so setting a 'global' skin fo ToggleButtons won't effect the ButtonBar buttons either. You should set them in a custom ButtonBarSkin as shown above. – Treur Feb 08 '12 at 14:48
  • its not a skin its a theme from those flash builder has available and i have applied one and changed many components in my app, and specifically its the GraphiteGraphical theme...and my question is: should i find where its file is and change the specific component i want to change(lets say the buttons) or if i create a new skin and apply it at a button its stronger(the skin) than the properties defined in the theme? hope it is more clear... – sstauross Feb 08 '12 at 15:01
  • Oh. Right. Well I'm not familiar with these kind of themes, so I wouldn't know exactly. You could try the method above, or you could try to ask this in a separate question, but there must be someone out here who can help you :) – Treur Feb 08 '12 at 15:17