Packagekm.components
Classpublic class ButtonGroup
InheritanceButtonGroup Inheritance flash.events.EventDispatcher

The ButtonGroup class.


Example
import km.components.*;
import km.skins.*;

var tf:TextField;
var b1:LabelButton, b2:LabelButton, b3:LabelButton;

// Add a dynamic textfield.

tf = new TextField();
addChild(tf);

// Add a label button component.

b1 = new LabelButton();
ScriptedSkin.applyTo(b1);
b1.setSize(90,24);
b1.move(20,30);
addChild(b1);

// Clone the first button and add the clone.
// This way we don't have to skin all buttons separately.

b2 = b1.clone();
b2.y = 60;
addChild(b2);
 
// Do the same for button three.
 
b3 = b1.clone();
b3.y = 90;
addChild(b3);

// Set the labels for the buttons

b1.label.text = 'Button 1';
b2.label.text = 'Button 2';
b3.label.text = 'Button 3';

// Create a button group and add the buttons

var bg:ButtonGroup = new ButtonGroup();
bg.addButton(b1, 1);
bg.addButton(b2, 2);
bg.addButton(b3, 3);

// Set the on change handler

bg.onChange = function(){
 tf.text = bg.data;
}



Public Properties
 PropertyDefined by
  data : *
[read-only] Gets the data associated with the selected button.
ButtonGroup
  onChange : Function
onChange handler.
ButtonGroup
  selected : *
Gets or sets the selected button.
ButtonGroup
Public Methods
 MethodDefined by
  
ButtonGroup(operationMode:int = 1)
ButtonGroup
  
addButton(button:*, data:* = null):void
Adds a button to the group.
ButtonGroup
  
removeButton(button:*):void
Removes a button from the group.
ButtonGroup
Events
 EventSummaryDefined by
   The change event is broadcasted when another button is selected.ButtonGroup
Property detail
dataproperty
data:*  [read-only]

Gets the data associated with the selected button.

Implementation
    public function get data():*
onChangeproperty 
public var onChange:Function

onChange handler.

selectedproperty 
selected:*  [read-write]

Gets or sets the selected button.

Implementation
    public function get selected():*
    public function set selected(value:*):void
Constructor detail
ButtonGroup()constructor
public function ButtonGroup(operationMode:int = 1)

Parameters
operationMode:int (default = 1) — 1 = hold, 2 = switch.
Method detail
addButton()method
public function addButton(button:*, data:* = null):void

Adds a button to the group.

Parameters
button:* — The button to add to the group.
 
data:* (default = null) — The data associated with the button.
removeButton()method 
public function removeButton(button:*):void

Removes a button from the group.

Parameters
button:* — The button to remove from the group.
Event detail
changeevent 
Event object type: flash.events.Event

The change event is broadcasted when another button is selected. It's also possible to use the onChange handler.