课程表

Flex课程

工具箱
速查手册

Flex RadioButton控件

当前位置:免费教程 » 软件/图像 » Flex

介绍

单选按钮控件允许用户在一组互相排斥的选择中进行单个选择。

类声明

以下是 spark.components.RadioButton 类的声明:

  1. public class RadioButton
  2. extends ToggleButtonBase
  3. implements IFocusManagerGroup

公共财产

S.N.属性和描述
1

enabled:Boolean

[override]如果启用单选按钮组并启用RadioButton本身,则启用单选按钮组件。

2

group:RadioButtonGroup

此RadioButton所属的RadioButtonGroup组件。

3

groupName:String

指定此RadioButton组件所属的组的名称,或者如果此RadioButton是由RadioButtonGroup组件定义的组的一部分,则指定RadioButtonGroup组件的id属性的值。

4

value:Object

与单选按钮组件相关联的可选用户定义值。

公共方法

S.N.方法和描述
1

RadioButton()

构造函数。

继承的方法

此类继承以下类中的方法:

  • spark.components.supportClasses.ToggleButtonBase

  • spark.components.supportClasses.ButtonBase

  • spark.components.supportClasses.SkinnableComponent

  • mx.core.UIComponent

  • mx.core.FlexSprite

  • flash.display.Sprite

  • flash.display.DisplayObjectContainer

  • flash.display.InteractiveObject

  • flash.display.DisplayObject

  • flash.events.EventDispatcher

  • Object

Flex单选按钮控件示例

让我们按照以下步骤通过创建测试应用程序来检查Flex应用程序中单选按钮控件的使用:

步骤描述
1 Flex - 创建应用程序章节中所述,在包 com.tutorialspoint.client 下创建名为 HelloWorld 的项目。
2修改 HelloWorld.mxml ,如下所述。 保持文件的其余部分不变。
3编译并运行应用程序,以确保业务逻辑按照要求工作。

以下是修改后的mxml文件 src / com.tutorialspoint / HelloWorld.mxml 的内容。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3. xmlns:s="library://ns.adobe.com/flex/spark"
  4. xmlns:mx="library://ns.adobe.com/flex/mx"
  5. width="100%" height="100%" minWidth="500" minHeight="500"
  6. >
  7. <fx:Style source="/com/tutorialspoint/client/Style.css"/>
  8. <fx:Script>
  9. <![CDATA[
  10. [Bindable]
  11. private var selectedOption:String = "";
  12.  
  13. protected function option_clickHandler(event:MouseEvent):void
  14. {
  15. var radioButton:RadioButton = event.target as RadioButton;
  16. switch (radioButton.id){
  17. case option1.id:
  18. selectedOption = option1.label;
  19. break;
  20. case option2.id:
  21. selectedOption = option2.label;
  22. break;
  23. case option3.id:
  24. selectedOption = option3.label;
  25. break;
  26. case option4.id:
  27. selectedOption = option4.label;
  28. break;
  29. }
  30. }
  31. ]]>
  32. </fx:Script>
  33. <s:BorderContainer width="550" height="400" id="mainContainer"
  34. styleName="container">
  35. <s:VGroup width="100%" height="100%" gap="50"
  36. horizontalAlign="center" verticalAlign="middle">
  37. <s:Label id="lblHeader" text="Form Controls Demonstration"
  38. fontSize="40" color="0x777777" styleName="heading"/>
  39. <s:Panel id="radioButtonPanel" title="Using RadioButton"
  40. width="420" height="200" >
  41. <s:layout>
  42. <s:VerticalLayout gap="10" verticalAlign="middle"
  43. horizontalAlign="center"/>
  44. </s:layout>
  45. <s:RadioButton groupName="options" id="option1"
  46. label="item #1" width="150"
  47. click="option_clickHandler(event)"/>
  48. <s:RadioButton groupName="options" id="option2"
  49. label="item #2" width="150"
  50. click="option_clickHandler(event)"/>
  51. <s:RadioButton groupName="options" id="option3"
  52. label="item #3" width="150"
  53. click="option_clickHandler(event)"/>
  54. <s:RadioButton groupName="options" id="option4"
  55. label="item #4" width="150"
  56. click="option_clickHandler(event)"/>
  57. <s:Label id="selectedOptionLabel" fontWeight="bold"
  58. text="Item selected: {selectedOption}" width="150"/>
  59. </s:Panel>
  60. </s:VGroup>
  61. </s:BorderContainer>
  62. </s:Application>

准备好所有更改后,让我们以正常模式编译和运行应用程序,就像在 Flex - 创建应用程序中一样 章节。 如果一切顺利,您的应用程序,这将产生以下结果:[在线试用]

Flex Radio Button Control
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号