Package | spark.components |
Class | public class RadioButtonGroup |
Inheritance | RadioButtonGroup EventDispatcher Object |
Implements | IMXMLObject |
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
id
property is required when you use the
<s:RadioButtonGroup>
tag to define the group name. Any
<s:RadioButton>
component added to this group will
have this group name.
Notice that the RadioButtonGroup component is a subclass of EventDispatcher,
not UIComponent, and implements the IMXMLObject interface.
All other Flex visual components implement the IVisualElement interface.
The RadioButtonGroup component declaration must
be contained within the <Declarations>
tag since it is
not assignable to IVisualElement.
To use this component in a list-based component, such as a List or DataGrid, create an item renderer. For information about creating an item renderer, see Custom Spark item renderers.
MXML SyntaxHide MXML SyntaxThe <s:RadioButtonGroup>
tag inherits all of the
tag attributes of its superclass, and adds the following tag attributes:
<s:RadioButtonGroup Properties enabled="true" selectedValue="null" selection="null" Events change="No default" itemClick="No default" valueCommit="No default" />
More examples
Related API Elements
Property | Defined By | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
enabled : Boolean
Determines whether selection is allowed. | RadioButtonGroup | ||
numRadioButtons : int [read-only]
The number of RadioButtons that belong to this RadioButtonGroup. | RadioButtonGroup | ||
selectedValue : Object
The value property of the selected
RadioButton component in the group, if it has been set,
otherwise, the label property of the selected RadioButton. | RadioButtonGroup | ||
selection : RadioButton
Contains a reference to the currently selected
RadioButton component in the group. | RadioButtonGroup |
Method | Defined By | ||
---|---|---|---|
RadioButtonGroup(document:IFlexDisplayObject = null)
Constructor. | RadioButtonGroup | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event. | EventDispatcher | ||
Dispatches an event into the event flow. | EventDispatcher | ||
Returns the RadioButton component at the specified index. | RadioButtonGroup | ||
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event. | EventDispatcher | ||
Indicates whether an object has a specified property defined. | Object | ||
Implementation of the IMXMLObject.initialized() method
to support deferred instantiation. | RadioButtonGroup | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Removes a listener from the EventDispatcher object. | EventDispatcher | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object | ||
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type. | EventDispatcher |
Event | Summary | Defined By | ||
---|---|---|---|---|
[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active. | EventDispatcher | |||
Dispatched when the value of the selected RadioButton component in this group changes. | RadioButtonGroup | |||
[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive. | EventDispatcher | |||
Dispatched when a user selects a RadioButton component in the group. | RadioButtonGroup | |||
Dispatched when values are changed programmatically or by user interaction. | RadioButtonGroup |
enabled | property |
enabled:Boolean
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Determines whether selection is allowed. Note that the value returned
only reflects the value that was explicitly set on the
RadioButtonGroup
and does not reflect any values explicitly
set on the individual RadioButtons.
The default value is true.
Implementation
public function get enabled():Boolean
public function set enabled(value:Boolean):void
numRadioButtons | property |
numRadioButtons:int
[read-only] Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
The number of RadioButtons that belong to this RadioButtonGroup.
The default value is "0".
This property can be used as the source for data binding. When this property is modified, it dispatches the numRadioButtonsChanged
event.
Implementation
public function get numRadioButtons():int
selectedValue | property |
selectedValue:Object
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
The value
property of the selected
RadioButton component in the group, if it has been set,
otherwise, the label
property of the selected RadioButton.
If no RadioButton is selected, this property is null
.
If you set selectedValue
, Flex selects the
first RadioButton component whose value
or
label
property matches this value.
The default value is null.
This property can be used as the source for data binding. When this property is modified, it dispatches the valueCommit
event.
Implementation
public function get selectedValue():Object
public function set selectedValue(value:Object):void
selection | property |
selection:RadioButton
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Contains a reference to the currently selected
RadioButton component in the group.
You can access this property in ActionScript only;
it is not settable in MXML.
Setting this property to null
deselects the currently
selected RadioButton component. A change event is not dispatched.
The default value is null.
This property can be used as the source for data binding. When this property is modified, it dispatches the valueCommit
event.
Implementation
public function get selection():RadioButton
public function set selection(value:RadioButton):void
RadioButtonGroup | () | Constructor |
public function RadioButtonGroup(document:IFlexDisplayObject = null)
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Constructor.
Parametersdocument:IFlexDisplayObject (default = null ) — In simple cases where a class extends EventDispatcher,
the document parameter should not be used.
|
Related API Elements
getRadioButtonAt | () | method |
public function getRadioButtonAt(index:int):RadioButton
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Returns the RadioButton component at the specified index.
Parameters
index:int — The 0-based index of the RadioButton in the
RadioButtonGroup.
|
RadioButton — The specified RadioButton component if index is between
0 and numRadioButtons - 1. Returns
null if the index is invalid.
|
Related API Elements
initialized | () | method |
public function initialized(document:Object, id:String):void
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Implementation of the IMXMLObject.initialized()
method
to support deferred instantiation.
Parameters
document:Object — The MXML document that created this object.
| |
id:String — The identifier used by document to refer to this object.
If the object is a deep property on document, id is null.
|
Related API Elements
change | Event |
flash.events.Event
property Event.type =
flash.events.Event.CHANGE
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Dispatched when the value of the selected RadioButton component in this group changes.
TheEvent.CHANGE
constant defines the value of the type
property of a change
event object.
This event has the following properties:
Property | Value |
---|---|
bubbles | true |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that has had its value modified.
The target is not always the object in the display list
that registered the event listener. Use the currentTarget
property to access the object in the display list that is currently processing the event. |
itemClick | Event |
mx.events.ItemClickEvent
property ItemClickEvent.type =
mx.events.ItemClickEvent.ITEM_CLICK
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Dispatched when a user selects a RadioButton component in the group. You can also set a handler for individual RadioButton components. This event is dispatched only when the user interacts with the radio buttons by using the mouse.
TheItemClickEvent.ITEM_CLICK
constant defines the value of the
type
property of the event object for an itemClick
event.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
index | The index of the navigation item that was clicked. |
item | The item in the data provider of the navigation item that was clicked. |
label | The label of the navigation item that was clicked. |
relatedObject | The child object that generated the event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
valueCommit | Event |
mx.events.FlexEvent
property FlexEvent.type =
mx.events.FlexEvent.VALUE_COMMIT
Language Version: | ActionScript 3.0 |
Product Version: | Flex 4 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Dispatched when values are changed programmatically or by user interaction.
Because a programmatic change triggers this event, make sure
that any valueCommit
event handler does not change
a value that causes another valueCommit
event.
For example, do not change theselectedValue
property or selection
property in a valueCommit
event handler.
FlexEvent.VALUE_COMMIT
constant defines the value of the
type
property of the event object for a valueCommit
event.
The properties of the event object have the following values:
Property | Value |
---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget . |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.ItemClickEvent; private function handlePayment(event:ItemClickEvent):void { if (event.currentTarget.selectedValue == "check") { Alert.show("You opted to pay by check."); } else if (event.currentTarget.selectedValue == "credit") { Alert.show("You opted to pay by credit card."); } } ]]> </fx:Script> <fx:Declarations> <s:RadioButtonGroup id="paymentType" itemClick="handlePayment(event);"/> </fx:Declarations> <s:VGroup paddingLeft="10" paddingTop="10"> <s:RadioButton groupName="paymentType" id="payCheck" value="check" label="Pay by check" width="150"/> <s:RadioButton groupName="paymentType" id="payCredit" value="credit" label="Pay by credit card" width="150"/> </s:VGroup> </s:Application>
Wed Nov 21 2018, 06:34 AM -08:00