| Pakiet | mx.controls |
| Klasa | public class RadioButtonGroup |
| Dziedziczenie | RadioButtonGroup EventDispatcher Object |
| Implementuje | IMXMLObject |
| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
![]() | Począwszy od Flex 4.0 firma Adobe zaleca użycie klasy spark.components.RadioButtonGroup jako zamiennika tej klasy. |
The RadioButtonGroup control defines a group of RadioButton controls that act as a single mutually exclusive control; therefore, a user can select only one RadioButton control at a time. While grouping RadioButton instances in a RadioButtonGroup is optional, a group lets you do things like set a single event handler on a group of buttons, rather than on each individual button.
The id property is required when you use the
<mx:RadioButtonGroup> tag to define the name
of the group.
Notice that the RadioButtonGroup control is a subclass of EventDispatcher, not UIComponent, and implements the IMXMLObject interface. All other Flex visual components are subclasses of UIComponent, which implements the IUIComponent interface. The RadioButtonGroup control has support built into the Flex compiler that allows you to use the RadioButtonGroup control as a child of a Flex container, even though it does not implement IUIComponent. All other container children must implement the IUIComponent interface.
Therefore, if you try to define a visual component as a subclass of EventDispatcher that implements the IMXMLObject interface, you will not be able to use it as the child of a container.
Składnia MXML
Ukryj składnię MXMLThe <mx:RadioButtonGroup> tag inherits all of the
tag attributes of its superclass, and adds the following tag attributes:
<mx:RadioButtonGroup
Properties
enabled="true|false"
id="No default"
labelPlacement="right|left|top|bottom"
Events
change="No default"
itemClick="No default"
/>
Powiązane elementy interfejsu API
| Właściwość | Zdefiniowane przez | ||
|---|---|---|---|
![]() | constructor : Object
Odwołanie do obiektu klasy lub funkcji konstruktora, dotyczące danej instancji obiektu. | Object | |
| enabled : Boolean
Determines whether selection is allowed. | RadioButtonGroup | ||
| labelPlacement : String
Position of the RadioButton label relative to the RadioButton icon
for each control in the group. | RadioButtonGroup | ||
| numRadioButtons : int [tylko do odczytu]
The number of RadioButtons that belong to this RadioButtonGroup. | RadioButtonGroup | ||
| selectedValue : Object
The value of the value property of the selected
RadioButton control in the group, if this has been set
to be something other than null (the default value). | RadioButtonGroup | ||
| selection : RadioButton
Contains a reference to the currently selected
RadioButton control in the group. | RadioButtonGroup | ||
| Metoda | Zdefiniowane przez | ||
|---|---|---|---|
RadioButtonGroup(document:IFlexDisplayObject = null)
Constructor. | RadioButtonGroup | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Rejestruje obiekt detektora zdarzeń w obiekcie EventDispatcher, dzięki czemu detektor będzie otrzymywał powiadomienia o zdarzeniu. | EventDispatcher | |
![]() |
Wywołuje zdarzenie, tj. kieruje je do przepływu zdarzeń. | EventDispatcher | |
Returns the RadioButton control at the specified index. | RadioButtonGroup | ||
![]() |
Sprawdza, czy obiekt EventDispatcher zawiera jakiekolwiek detektory zarejestrowane dla konkretnego typu zdarzeń. | EventDispatcher | |
![]() |
Wskazuje, czy dla obiektu zdefiniowano określoną właściwość. | Object | |
Implementation of the IMXMLObject.initialized() method
to support deferred instantiation. | RadioButtonGroup | ||
![]() |
Wskazuje, czy instancja klasy Object należy do łańcucha prototypów obiektu określonego jako parametr. | Object | |
![]() |
Wskazuje, czy określona właściwość istnieje i jest przeliczalna. | Object | |
![]() |
Usuwa detektor z obiektu EventDispatcher. | EventDispatcher | |
![]() |
Ustawia dostępność właściwości dynamicznej używanej w pętlach. | Object | |
![]() |
Zwraca ciąg reprezentujący obiekt — sformatowany zgodnie z konwencjami właściwymi dla ustawień regionalnych. | Object | |
![]() |
Zwraca ciąg reprezentujący określony obiekt. | Object | |
![]() |
Zwraca pierwotną wartość dla określonego obiektu. | Object | |
![]() |
Sprawdza, czy detektor zdarzeń określonego typu jest zarejestrowany w tym obiekcie EventDispatcher lub jego elementach macierzystych. | EventDispatcher | |
| Zdarzenie | Podsumowanie | Zdefiniowane przez | ||
|---|---|---|---|---|
![]() | [zdarzenie broadcast] Wywoływane, gdy program Flash Player lub aplikacja środowiska wykonawczego AIR uzyskuje fokus w systemie operacyjnym i przechodzi w stan aktywny. | EventDispatcher | ||
| Dispatched when the value of the selected RadioButton control in this group changes. | RadioButtonGroup | |||
![]() | [zdarzenie broadcast] Wywoływane, gdy program Flash Player lub aplikacja AIR traci fokus w systemie operacyjnym i przechodzi w stan nieaktywny. | EventDispatcher | ||
| Dispatched when a user selects a RadioButton control in the group. | RadioButtonGroup | |||
enabled | właściwość |
enabled:Boolean| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Determines whether selection is allowed.
Wartością domyślną jest true.
Ta właściwość może być używana jako źródło dla tworzenia powiązań danych. Jeśli ta właściwość zostanie zmodyfikowana, zostanie wywołane zdarzenie enabledChanged .
Implementacja
public function get enabled():Boolean public function set enabled(value:Boolean):voidlabelPlacement | właściwość |
labelPlacement:String| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Position of the RadioButton label relative to the RadioButton icon for each control in the group. You can override this setting for the individual controls.
Valid values in MXML are "right", "left",
"bottom", and "top".
In ActionScript, you use the following constants to set this property:
ButtonLabelPlacement.RIGHT, ButtonLabelPlacement.LEFT,
ButtonLabelPlacement.BOTTOM, and ButtonLabelPlacement.TOP.
Wartością domyślną jest "right".
Ta właściwość może być używana jako źródło dla tworzenia powiązań danych. Jeśli ta właściwość zostanie zmodyfikowana, zostanie wywołane zdarzenie labelPlacementChanged .
Implementacja
public function get labelPlacement():String public function set labelPlacement(value:String):voidnumRadioButtons | właściwość |
numRadioButtons:int [tylko do odczytu] | Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
The number of RadioButtons that belong to this RadioButtonGroup.
Wartością domyślną jest "undefined".
Ta właściwość może być używana jako źródło dla tworzenia powiązań danych. Jeśli ta właściwość zostanie zmodyfikowana, zostanie wywołane zdarzenie numRadioButtonsChanged .
Implementacja
public function get numRadioButtons():intselectedValue | właściwość |
selectedValue:Object| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
The value of the value property of the selected
RadioButton control in the group, if this has been set
to be something other than null (the default value).
Otherwise, selectedValue is the value of the
label property of the selected RadioButton.
If no RadioButton is selected, this property is null.
If you set selectedValue, Flex selects the
RadioButton control whose value or
label property matches this value.
Wartością domyślną jest null.
Ta właściwość może być używana jako źródło dla tworzenia powiązań danych. Jeśli ta właściwość zostanie zmodyfikowana, zostanie wywołane zdarzenie valueCommit .
Implementacja
public function get selectedValue():Object public function set selectedValue(value:Object):voidselection | właściwość |
selection:RadioButton| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Contains a reference to the currently selected
RadioButton control in the group.
You can access the property in ActionScript only;
it is not settable in MXML.
Setting this property to null deselects the currently selected RadioButton control.
Wartością domyślną jest null.
Ta właściwość może być używana jako źródło dla tworzenia powiązań danych. Jeśli ta właściwość zostanie zmodyfikowana, zostanie wywołane zdarzenie valueCommit .
Implementacja
public function get selection():RadioButton public function set selection(value:RadioButton):voidRadioButtonGroup | () | Konstruktor |
public function RadioButtonGroup(document:IFlexDisplayObject = null)| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Constructor.
Parametrydocument:IFlexDisplayObject (default = null) — In simple cases where a class extends EventDispatcher,
the document parameter should not be used.
|
Powiązane elementy interfejsu API
getRadioButtonAt | () | metoda |
public function getRadioButtonAt(index:int):RadioButton| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Returns the RadioButton control at the specified index.
Parametry
index:int — The index of the RadioButton control in the
RadioButtonGroup control, where the index of the first control is 0.
|
RadioButton — The specified RadioButton control.
|
initialized | () | metoda |
public function initialized(document:Object, id:String):void| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Implementation of the IMXMLObject.initialized() method
to support deferred instantiation.
Parametry
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.
|
Powiązane elementy interfejsu API
change | Zdarzenie |
flash.events.Eventwłaściwość Event.type =
flash.events.Event.CHANGE| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Dispatched when the value of the selected RadioButton control in this group changes.
StałaEvent.CHANGE definiuje wartość właściwości type obiektu zdarzenia change.
To zdarzenie ma następujące właściwości:
| Właściwość | Wartość |
|---|---|
bubbles | true |
cancelable | false; nie ma domyślnego zachowania, które można byłoby anulować. |
currentTarget | Obiekt przetwarzający aktywnie obiekt Event za pomocą detektora zdarzeń. |
target | Wartość obiektu została zmodyfikowana. Obiekt target nie zawsze jest obiektem na liście wyświetlania, która zarejestrowała detektor zdarzeń. Właściwość currentTarget umożliwia uzyskanie dostępu do obiektu na liście wyświetlania, który obecnie przetwarza zdarzenie. |
itemClick | Zdarzenie |
mx.events.ItemClickEventwłaściwość ItemClickEvent.type =
mx.events.ItemClickEvent.ITEM_CLICK| Wersja języka: | ActionScript 3.0 |
| Wersja produktu: | Flex 3 |
| Wersje środowiska wykonawczego: | Flash Player 9, AIR 1.1 |
Dispatched when a user selects a RadioButton control in the group. You can also set a handler for individual RadioButton controls.
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. |
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate Halo RadioButtonGroup control. -->
<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;
// Event handler function to display the selected button
// in a Halo Alert control.
private function handleCard(evt:ItemClickEvent):void {
switch (evt.currentTarget.selectedValue) {
case "AmEx":
Alert.show("You selected American Express");
break;
case "MC":
Alert.show("You selected MasterCard");
break;
case "Visa":
Alert.show("You selected Visa");
break;
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:RadioButtonGroup id="cardtype" itemClick="handleCard(event);"/>
</fx:Declarations>
<s:Panel title="Halo RadioButtonGroup Control Example"
width="75%" height="75%"
horizontalCenter="0" verticalCenter="0">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:Label width="100%" color="blue"
text="Select a type of credit card."/>
<mx:RadioButton groupName="cardtype" id="americanExpress" value="AmEx"
label="American Express" width="150" />
<mx:RadioButton groupName="cardtype" id="masterCard" value="MC"
label="MasterCard" width="150" />
<mx:RadioButton groupName="cardtype" id="visa" value="Visa"
label="Visa" width="150" />
</s:VGroup>
</s:Panel>
</s:Application>
Tue Jun 12 2018, 12:06 PM Z

Pokaż składnię MXML