Pacotemx.controls
Classeclasse pública RadioButtonGroup
HerançaRadioButtonGroup Inheritance EventDispatcher Inheritance Object
Implementos IMXMLObject

O controle RadioButtonGroup define um grupo de controles RadioButton que aje como um controle único mutuamente exclusive; portanto, o usuário pode selecionar apenas um controle RadioButton de uma vez. 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, event 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.

Sintaxe MXMLexpandedOcultar Sintaxe MXML

The <mx:RadioButtonGroup> tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:

  <mx:RadioButtonGroup
    Propriedades
    enabled="true|false"      
    id="No default"
    labelPlacement="right|left|top|bottom"
  
    Eventos
    change="No default"
    itemClick="No default"
  />
  

Veja os exemplos

Ver também

mx.controls.RadioButton


Propriedades Públicas
 PropriedadeDefinido Por
 Inheritedconstructor : Object
Uma referência ao objeto da classe ou função construtora para uma instância determinada de um objeto.
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
[leitura-somente] The number of RadioButtons that belong to this RadioButtonGroup.
RadioButtonGroup
 Inheritedprototype : Object
[static] Uma referência ao objeto protótipo de uma classe ou função de objeto.
Object
  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
Métodos Públicos
 MétodoDefinido Por
  
Constructor.
RadioButtonGroup
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registra um objeto event listener com um objeto do EventDispatcher para que o listener receba notificação de um evento.
EventDispatcher
 Inherited
Despacha um evento no fluxo de eventos.
EventDispatcher
  
Returns the RadioButton control at the specified index.
RadioButtonGroup
 Inherited
Verifica se o objeto do EventDispatcher tem listeners registrados para um tipo determinado de evento.
EventDispatcher
 Inherited
Indica se um objeto tem uma propriedade específica definida.
Object
  
initialized(document:Object, id:String):void
Implementation of the IMXMLObject.initialized() method to support deferred instantiation.
RadioButtonGroup
 Inherited
Indica se uma instância da classe Object está na corrente do protótipo do objeto determinado como parâmetro.
Object
 Inherited
Indica se a propriedade especificada existe e se é enumerável.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Remove um listener do objeto do EventDispatcher.
EventDispatcher
 Inherited
Determina a disponibilidade de uma propriedade dinâmica para operações em loop.
Object
 Inherited
Retorna a representação em string de um objeto determinado.
Object
 Inherited
Retorna o valor primitivo de um objeto específico.
Object
 Inherited
Verifica se um event listener está registrado com esse objeto do EventDispatcher ou qualquer um de seus parents para o determinado tipo de evento.
EventDispatcher
Eventos
 Evento Sumário Definido Por
 Inherited Despachado quando o Flash Player ou um aplicativo AIR obtém foco do sistema operacional e se torna ativo.EventDispatcher
   Dispatched when the value of the selected RadioButton control in this group changes.RadioButtonGroup
 Inherited Despachado quando o Flash Player ou um aplicativo AIR perde o foco do sistema operacional e está se tornando inativo.EventDispatcher
   Dispatched when a user selects a RadioButton control in the group.RadioButtonGroup
Detalhe da Propriedade
enabledpropriedade
enabled:Boolean  [ler-escrever]

Determines whether selection is allowed.

O valor padrão é true.

Essa propriedade pode ser usada como a fonte para a união de dados.


Implementação
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
labelPlacementpropriedade 
labelPlacement:String  [ler-escrever]

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".

Em ActionScript, você usa as seguintes constantes para ajustar essa propriedade: ButtonLabelPlacement.RIGHT, ButtonLabelPlacement.LEFT, ButtonLabelPlacement.BOTTOM, and ButtonLabelPlacement.TOP.

O valor padrão é "right".

Essa propriedade pode ser usada como a fonte para a união de dados.


Implementação
    public function get labelPlacement():String
    public function set labelPlacement(value:String):void
numRadioButtonspropriedade 
numRadioButtons:int  [leitura-somente]

The number of RadioButtons that belong to this RadioButtonGroup.

O valor padrão é "undefined".

Essa propriedade pode ser usada como a fonte para a união de dados.


Implementação
    public function get numRadioButtons():int
selectedValuepropriedade 
selectedValue:Object  [ler-escrever]

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.

O valor padrão é null.

Essa propriedade pode ser usada como a fonte para a união de dados.


Implementação
    public function get selectedValue():Object
    public function set selectedValue(value:Object):void
selectionpropriedade 
selection:RadioButton  [ler-escrever]

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.

O valor padrão é null.

Essa propriedade pode ser usada como a fonte para a união de dados.


Implementação
    public function get selection():RadioButton
    public function set selection(value:RadioButton):void
Detalhe do Construtor
RadioButtonGroup()Construtor
public function RadioButtonGroup(document:IFlexDisplayObject = null)

Constructor.

Parâmetros
document:IFlexDisplayObject (default = null) — In simple cases where a class extends EventDispatcher, the document parameter should not be used.

Ver também

Detalhe do Método
getRadioButtonAt()método
public function getRadioButtonAt(index:int):RadioButton

Returns the RadioButton control at the specified index.

Parâmetros

index:int — The index of the RadioButton control in the RadioButtonGroup control, where the index of the first control is 0.

Retorna
RadioButton — The specified RadioButton control.
initialized()método 
public function initialized(document:Object, id:String):void

Implementation of the IMXMLObject.initialized() method to support deferred instantiation.

Parâmetros

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.

Ver também

Detalhe do Evento
change Evento
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.CHANGE

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

A constante Event.CHANGE define o valor da propriedade de tipo de um objeto de evento change.

This event has the following properties:

PropriedadeValor
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetO objeto que está ativamente processando o objeto Event com um event listener.
targetThe 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 Evento  
Event Object Type: mx.events.ItemClickEvent
ItemClickEvent.type property = mx.events.ItemClickEvent.ITEM_CLICK

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.

As propriedades do objeto de evento tem os seguintes valores:

PropriedadeValor
bubblesfalse
cancelablefalse
currentTargetO Object que define o event listener que cuida do evento. Por exemplo, se você usar o myButton.addEventListener() para registrar um event listener, myButton é o valor do 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.
targetO Object que despachou o evento; nem sempre é o Object que escuta pelo evento. Use a propriedade currentTarget para sempre acessar o Objeto que faz a escuta pelo evento.
Exemplos Como usar exemplos
RadioButtonGroupExample.mxml
<?xml version="1.0"?>
<!-- Simple example to demonstrate RadioButtonGroup control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[
    
        import mx.controls.Alert;
        import  mx.events.ItemClickEvent;
    
        // Event handler function to display the selected button
        // in an Alert control.
        private function handleCard(event:ItemClickEvent):void {
            if (event.currentTarget.selectedValue == "AmEx") {
                    Alert.show("You selected American Express") 
            } 
            else {
                if (event.currentTarget.selectedValue == "MC") {
                    Alert.show("You selected MasterCard") 
                } 
                else {
                    Alert.show("You selected Visa") 
                }
            } 
        }
        ]]>
    </mx:Script>

    <mx:Panel title="RadioButtonGroup Control Example" height="75%" width="75%" 
        paddingTop="10" paddingLeft="10">
    
        <mx:Label width="100%" color="blue" 
            text="Select a type of credit card."/>

        <mx:RadioButtonGroup id="cardtype" itemClick="handleCard(event);"/>
        <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" />
        
    </mx:Panel>        
</mx:Application>