fx:Declaration 中的 RadioButtonGroup 声明
Declaration of RadioButtonGroup in fx:Declaration
我的 Flex 代码在 fx:declaration 部分声明了单选按钮组,用于非图形用户界面组件。
<fx:Declarations>
<s:RadioButtonGroup id="rdbtnlan"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
这样做的目的是什么?这些按钮的使用如下:
protected function rdbtn1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(rdbtnlan.selection.value == "Eng")
var dbResult:SQLResult = sqlcon.SQLCon("Update setting Set Language ='Eng'");
else if(rdbtnlan.selection.value == "Hindi")
var dbResult:SQLResult = sqlcon.SQLCon("Update setting Set Language ='Hindi'");
init();
}
此外,按钮在其标签中引用了单选按钮组:
<s:VGroup x="241" y="366" horizontalAlign="left" styleName="tabStyle" layoutDirection="ltr" id="rdbtn1">
<s:RadioButton id="rdSetEng" label="English" color="Black" groupName="rdbtnlan"
value="Eng" click="rdbtn1_clickHandler(event)"/>
<s:RadioButton id="rdSetHindi" label="Hindi" color="Black" groupName="rdbtnlan"
value="Hindi" click="rdbtn1_clickHandler(event)"/>
</s:VGroup>
如 documentation 所述:
The RadioButtonGroup component defines a group of RadioButton components that act as a single mutually exclusive component; therefore, a user can select only one RadioButton component at a time.
请注意,您的代码段包括:
if(rdbtnlan.selection.value == "Eng")
rdbtnlan
是 按钮组 ,而不是对特定按钮的引用。你问的是 "What is the value selected for this group of buttons?"
如果没有按钮组,您需要遍历组件中的所有按钮并单独检查它们,例如
if (rdSetEng.selected) {
var dbResult:SQLResult // ...
else if (rdSetHindi.selected) {
var dbResult:SQLResult // ...
}
另请注意,您无法保证 rdSetEng
和 rdSetHindi
都未被选中——您必须编写逻辑来取消选择每个按钮 [=] 中的其他单选按钮15=]处理程序。
我的 Flex 代码在 fx:declaration 部分声明了单选按钮组,用于非图形用户界面组件。
<fx:Declarations>
<s:RadioButtonGroup id="rdbtnlan"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
这样做的目的是什么?这些按钮的使用如下:
protected function rdbtn1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(rdbtnlan.selection.value == "Eng")
var dbResult:SQLResult = sqlcon.SQLCon("Update setting Set Language ='Eng'");
else if(rdbtnlan.selection.value == "Hindi")
var dbResult:SQLResult = sqlcon.SQLCon("Update setting Set Language ='Hindi'");
init();
}
此外,按钮在其标签中引用了单选按钮组:
<s:VGroup x="241" y="366" horizontalAlign="left" styleName="tabStyle" layoutDirection="ltr" id="rdbtn1">
<s:RadioButton id="rdSetEng" label="English" color="Black" groupName="rdbtnlan"
value="Eng" click="rdbtn1_clickHandler(event)"/>
<s:RadioButton id="rdSetHindi" label="Hindi" color="Black" groupName="rdbtnlan"
value="Hindi" click="rdbtn1_clickHandler(event)"/>
</s:VGroup>
如 documentation 所述:
The RadioButtonGroup component defines a group of RadioButton components that act as a single mutually exclusive component; therefore, a user can select only one RadioButton component at a time.
请注意,您的代码段包括:
if(rdbtnlan.selection.value == "Eng")
rdbtnlan
是 按钮组 ,而不是对特定按钮的引用。你问的是 "What is the value selected for this group of buttons?"
如果没有按钮组,您需要遍历组件中的所有按钮并单独检查它们,例如
if (rdSetEng.selected) {
var dbResult:SQLResult // ...
else if (rdSetHindi.selected) {
var dbResult:SQLResult // ...
}
另请注意,您无法保证 rdSetEng
和 rdSetHindi
都未被选中——您必须编写逻辑来取消选择每个按钮 [=] 中的其他单选按钮15=]处理程序。