適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: 從伺服器擷取資料...
從伺服器擷取資料...
mx.controls 

RadioButtonGroup  - AS3 Flex

套件mx.controls
類別public class RadioButtonGroup
繼承RadioButtonGroup Inheritance EventDispatcher Inheritance Object
實作 IMXMLObject

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1


使用 Flex 4.0 開始,Adobe 建議您使用 spark.components.RadioButtonGroup 類別當作是此類別的替代類別。

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.

MXML 語法expanded隱藏 MXML 語法

The <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"
  />
  

檢視範例

更多範例

相關 API 元素



公用屬性
 屬性定義自
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
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
[唯讀] 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
公用方法
 方法定義自
  
Constructor.
RadioButtonGroup
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
 Inherited
會將事件傳送到事件流程。
EventDispatcher
  
Returns the RadioButton control at the specified index.
RadioButtonGroup
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
  
Implementation of the IMXMLObject.initialized() method to support deferred instantiation.
RadioButtonGroup
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
  Dispatched when the value of the selected RadioButton control in this group changes.RadioButtonGroup
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
  Dispatched when a user selects a RadioButton control in the group.RadioButtonGroup
屬性詳細資訊

enabled

屬性
enabled:Boolean

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

Determines whether selection is allowed.

預設值為 true。

此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 enabledChanged 事件。



實作
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void

labelPlacement

屬性 
labelPlacement:String

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: 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.

預設值為 "right"。

此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 labelPlacementChanged 事件。



實作
    public function get labelPlacement():String
    public function set labelPlacement(value:String):void

numRadioButtons

屬性 
numRadioButtons:int  [唯讀]

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

The number of RadioButtons that belong to this RadioButtonGroup.

預設值為 "undefined"。

此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 numRadioButtonsChanged 事件。



實作
    public function get numRadioButtons():int

selectedValue

屬性 
selectedValue:Object

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: 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.

預設值為 null。

此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 valueCommit 事件。



實作
    public function get selectedValue():Object
    public function set selectedValue(value:Object):void

selection

屬性 
selection:RadioButton

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: 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.

預設值為 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 3
執行階段版本: Flash Player 9, AIR 1.1

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 3
執行階段版本: Flash Player 9, AIR 1.1

Returns the RadioButton control at the specified index.

參數

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

()方法 
public function initialized(document:Object, id:String):void

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: Flash Player 9, AIR 1.1

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 3
執行階段版本: Flash Player 9, AIR 1.1

Dispatched when the value of the selected RadioButton control in this group changes.

Event.CHANGE 常數會定義 change 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblestrue
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target其值遭到修改的物件。 target 不會永遠都是顯示清單中註冊事件偵聽程式的物件。 請使用 currentTarget 屬性,存取目前正在處理該事件之顯示清單中的物件。

itemClick

事件  
事件物件類型: mx.events.ItemClickEvent
屬性 ItemClickEvent.type = mx.events.ItemClickEvent.ITEM_CLICK

語言版本: ActionScript 3.0
產品版本: Flex 3
執行階段版本: 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.

The ItemClickEvent.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:

PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe 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.
indexThe index of the navigation item that was clicked.
itemThe item in the data provider of the navigation item that was clicked.
labelThe label of the navigation item that was clicked.
relatedObjectThe child object that generated the event.
targetThe 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.
RadioButtonGroupExample.mxml
<?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>




[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。