RadioButton 组件使用户可在一组互相排斥的选择中做出一种选择。RadioButtonGroup 包含具有相同 groupName 属性的两个或更多 RadioButton 组件。当可以选择在 RadioButtonGroup 中组合 RadioButton 实例时,组使您能够执行诸如在一组 RadioButton 上(而不是在每个单独的 RadioButton 上)设置单一事件处理函数等事项。
RadioButton 组可以引用 <s:RadioButtonGroup> 标签创建的组。用户一次只能选择此组中的一个成员。选择未选中的组成员将取消选择该组中当前所选的 RadioButton 组件。
要在基于列表的组件(如 List 或 DataGrid)中使用此组件,请创建项呈示器。有关创建项呈示器的信息,请参阅自定义 Spark 项呈示器。
RadioButton 组件具有以下默认特征:
隐藏 MXML 语法
The <s:RadioButton> tag inherits all of the tag
attributes of its superclass, and adds the following tag attributes:
<s:RadioButton
Properties
enabled=""
group="the automatically created default RadioButtonGroup"
groupName="radioGroup"
value="null"
/>
label
查看示例
样式为常见样式,或与特定主题关联。如果为常见样式,则可以用于任何主题。如果样式与特定主题关联,则只有应用程序使用该主题时才能使用该样式。
语言版本: ActionScript 3.0
产品版本: Flex 4
运行时版本: Flash10, AIR 1.5
与标签相关的图标的方向。有效的 MXML 值是 right、left、bottom 和 top。
在 ActionScript 中,您可以使用下列常量来设置此属性:IconPlacement.RIGHT、IconPlacement.LEFT、IconPlacement.BOTTOM 和 IconPlacement.TOP。
默认值为 IconPlacement.LEFT。
enabled:Boolean[覆盖]
如果 RadioButtonGroup 启用,则 RadioButton 组件启用,且 RadioButton 本身也启用。
override public function get enabled():Boolean override public function set enabled(value:Boolean):void
group:RadioButtonGroup
此 RadioButton 所属的 RadioButtonGroup 组件。创建要放入 RadioButtonGroup 中的 RadioButton 时,应该对所有按钮使用 group 属性或者 groupName 属性。
默认值为 the automatically created default RadioButtonGroup。
public function get group():RadioButtonGroup public function set group(value:RadioButtonGroup):void
groupName:String
指定此 RadioButton 组件所属的组的名称,或者,如果此 RadioButton 是 RadioButtonGroup 组件定义的组的一部分,则指定 RadioButtonGroup 组件的 ID 属性值。具有相同 groupName 属性的所有单选按钮都将位于同一个选项卡组。
创建要放入 RadioButtonGroup 中的单选按钮时,建议对所有按钮使用 group 属性或者 groupName 属性。
默认值为 "radioGroup"。
public function get groupName():String public function set groupName(value:String):void
value:Object
与 RadioButton 组件关联的可选用户定义值。
默认值为 null。
此属性可用作数据绑定的源。修改此属性后,将调度 valueChanged 事件。
public function get value():Object public function set value(value:Object):void
public function RadioButton()
构造函数。
<?xml version="1.0"?>
<!-- controlsbuttonRBEvent.mxml -->
<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 flash.events.Event;
private function handleNonstop(event:Event):void {
// Handle event.
myTA.text="You selected nonstop flights";
}
private function handleOneStop(event:Event):void {
// Handle event.
myTA.text="You selected one stop";
}
private function handleTwoStops(event:Event):void {
// Handle event.
myTA.text="You selected two stops";
}
]]>
</fx:Script>
<s:VGroup paddingLeft="10" paddingTop="10">
<s:RadioButton groupName="numStops"
id="nonStop"
label="Nonstop flights only"
width="150"
click="handleNonstop(event);"/>
<s:RadioButton groupName="numStops"
id="oneStop"
label="One stop"
width="150"
click="handleOneStop(event);"/>
<s:RadioButton groupName="numStops"
id="twoStops"
label="Two stops"
width="150"
click="handleTwoStops(event);"/>
<s:TextArea id="myTA"/>
</s:VGroup>
</s:Application>
显示 MXML 语法









