套件 | spark.components |
類別 | public class RadioButtonGroup |
繼承 | RadioButtonGroup EventDispatcher Object |
實作 | IMXMLObject |
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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 語法隱藏 MXML 語法The <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" />
更多範例
相關 API 元素
屬性 | 定義自 | ||
---|---|---|---|
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
enabled : Boolean
Determines whether selection is allowed. | RadioButtonGroup | ||
numRadioButtons : int [唯讀]
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 |
方法 | 定義自 | ||
---|---|---|---|
RadioButtonGroup(document:IFlexDisplayObject = null)
Constructor. | RadioButtonGroup | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
Returns the RadioButton component at the specified index. | RadioButtonGroup | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
Implementation of the IMXMLObject.initialized() method
to support deferred instantiation. | RadioButtonGroup | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
會傳回指定之物件的字串形式。 | Object | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
事件 | 摘要 | 定義自 | ||
---|---|---|---|---|
[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。 | EventDispatcher | |||
Dispatched when the value of the selected RadioButton component in this group changes. | RadioButtonGroup | |||
[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。 | 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 | 屬性 |
enabled:Boolean
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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.
預設值為 true。
實作
public function get enabled():Boolean
public function set enabled(value:Boolean):void
numRadioButtons | 屬性 |
selectedValue | 屬性 |
selectedValue:Object
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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.
預設值為 null。
此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 valueCommit
事件。
實作
public function get selectedValue():Object
public function set selectedValue(value:Object):void
selection | 屬性 |
selection:RadioButton
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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.
預設值為 null。
此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 valueCommit
事件。
實作
public function get selection():RadioButton
public function set selection(value:RadioButton):void
RadioButtonGroup | () | 建構函式 |
public function RadioButtonGroup(document:IFlexDisplayObject = null)
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Constructor.
參數document:IFlexDisplayObject (default = null ) — In simple cases where a class extends EventDispatcher,
the document parameter should not be used.
|
相關 API 元素
getRadioButtonAt | () | 方法 |
public function getRadioButtonAt(index:int):RadioButton
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Returns the RadioButton component at the specified index.
參數
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.
|
相關 API 元素
initialized | () | 方法 |
public function initialized(document:Object, id:String):void
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Implementation of the IMXMLObject.initialized()
method
to support deferred instantiation.
參數
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.
|
相關 API 元素
change | 事件 |
flash.events.Event
屬性 Event.type =
flash.events.Event.CHANGE
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Dispatched when the value of the selected RadioButton component in this group changes.
Event.CHANGE
常數會定義 change
事件物件的 type
屬性值。
這個事件具有下列屬性:
屬性 | 值 |
---|---|
bubbles | true |
cancelable | false ;沒有要取消的預設行為指令。 |
currentTarget | 正主動使用事件偵聽程式處理 Event 物件的物件。 |
target | 其值遭到修改的物件。 target 不會永遠都是顯示清單中註冊事件偵聽程式的物件。 請使用 currentTarget 屬性,存取目前正在處理該事件之顯示清單中的物件。 |
itemClick | 事件 |
mx.events.ItemClickEvent
屬性 ItemClickEvent.type =
mx.events.ItemClickEvent.ITEM_CLICK
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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 | 事件 |
mx.events.FlexEvent
屬性 FlexEvent.type =
mx.events.FlexEvent.VALUE_COMMIT
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4 |
執行階段版本: | 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>
Tue Jun 12 2018, 03:47 PM Z