动态添加单选按钮组
我正在尝试在 Flex 中进行测验,并从 xml 文件加载数据。对于每个问题,我想创建一个单选按钮组,以便我可以将单选按钮与其关联。我怎样才能用动作脚本来实现这一点?我可以看到 addChild 方法适用于 DisplayObjects,并且我认为 radiobuttongroup 不是一个方法,因为我收到错误。如何在 Flex 应用程序中使用 ActionScript 动态添加单选按钮组?谢谢。
I'm trying to make a quiz in flex and am loading data from an xml file. For each question I want to create a radiobuttongroup so I can associate radio buttons to it. How can I accomplish that with actionscript? I can see that addChild method works for DisplayObjects and I presume that radiobuttongroup is not one because I'm receiving errors. How can I dynamically add radiobuttongroup with actionscript in flex application? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果将单选按钮添加到 FormItem,它们会自动分组在一起。因此,假设您的测验使用 Flex Form 进行布局,您只需为每个问题生成一个 FormItem,为每个选项添加一个按钮到 FormItem,然后将该 FormItem 添加到您的主 Form。
If you add radio buttons to a FormItem, they are automatically grouped together. So, assuming your quiz uses a Flex Form for layout, you simply generate a FormItem for each question, add a button for each option to the FormItem, then add that FormItem to your main Form.
您创建单选按钮,将它们添加到显示中,为它们创建一个组并声明单选按钮属于同一组 (
RadioButton.group = group1
)。 RadioButtonGroup 确实不是一个显示对象,而只是告诉属于该组的单选按钮它们应该充当一个元素。http://livedocs.adobe.com/flash/9.0/ ActionScriptLangRefV3/fl/controls/RadioButtonGroup.html
http ://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/RadioButton.html
You create the radio buttons, add them to the display, create a group for them and declare the radio buttons to belong to the same group (
RadioButton.group = group1
). The RadioButtonGroup is indeed not a display object but just tells the radio buttons belonging to that group that they should acts as one element.http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/RadioButtonGroup.html
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/RadioButton.html