如何在运行时访问通过 ActionScript 创建的 tabNavigator 的子成员?
我正在 mxml 中创建 tabNavigator 对象。
TabNavigator 包含 navigatorContent 对象。
每个 NavigatorContent 还包含多个 hGroup,其中包含三个单选按钮。
所有这些元素都通过actionScript 代码动态填充在tabNavigator 中。
我需要选择 hgroup 中的第二个单选按钮,但我不确定如何执行此操作。
<mx:TabNavigator id="tabNav" height="100" width="500" creationComplete="init();" creationPolicy="all">
</mx:TabNavigator>
private function init():void
{
for(var i:int=0;i<=int(arrColl_items[arrColl_items.length - 1][1]);
i++)
{
//after reading from xml var navContent:NavigatorContent = new NavigatorContent();
for (var j:int=0;j<arrColl_items.length;j++)
{
if(arrColl_items[j][1] == i)
{
var hgrp:HGroup = new HGroup();
hgrp.id = String(arrColl_items[j][0]);
var rdBut1:RadioButton=new RadioButton();
hgrp.addElement(rdBut1);
rdBut1.addEventListener(MouseEvent.CLICK, setrdBut1);
var rdBut2:RadioButton=new RadioButton();
hgrp.addElement(rdBut2);
rdBut2.addEventListener(MouseEvent.CLICK, setrdBut2);
var rdBut3:RadioButton=new RadioButton();
hgrp.addElement(rdBut3);
rdBut3.addEventListener(MouseEvent.CLICK, setrdBut3);
}
}
navContent.addElement(hgrp);
tabNav.addChildAt(navContent,i);
}
}
有人可以帮忙吗?
问候
阿帕纳
I am creating a tabNavigator object in mxml.
TabNavigator contains navigatorContent objects.
Each NavigatorContent further contains multiple hGroups with three radio buttons in it.
All these elements are populated in the tabNavigator via actionScript code dynamically.
I need to select the second radio button within an hgroup, but am not sure how to do this.
<mx:TabNavigator id="tabNav" height="100" width="500" creationComplete="init();" creationPolicy="all">
</mx:TabNavigator>
private function init():void
{
for(var i:int=0;i<=int(arrColl_items[arrColl_items.length - 1][1]);
i++)
{
//after reading from xml var navContent:NavigatorContent = new NavigatorContent();
for (var j:int=0;j<arrColl_items.length;j++)
{
if(arrColl_items[j][1] == i)
{
var hgrp:HGroup = new HGroup();
hgrp.id = String(arrColl_items[j][0]);
var rdBut1:RadioButton=new RadioButton();
hgrp.addElement(rdBut1);
rdBut1.addEventListener(MouseEvent.CLICK, setrdBut1);
var rdBut2:RadioButton=new RadioButton();
hgrp.addElement(rdBut2);
rdBut2.addEventListener(MouseEvent.CLICK, setrdBut2);
var rdBut3:RadioButton=new RadioButton();
hgrp.addElement(rdBut3);
rdBut3.addEventListener(MouseEvent.CLICK, setrdBut3);
}
}
navContent.addElement(hgrp);
tabNav.addChildAt(navContent,i);
}
}
Can anyone please help out on this?
Regards
Aparna
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有发布数据结构,我希望我是对的。以下演示使用三个 NavigatorContent 实例创建并填充 TabNavigator,其中包含一系列可使用“getHGroupById”方法进行选择的 RadioButton。
我确信使用 Bindable Data 和 ItemRenderes 可以实现类似的东西,这可能是更好的解决方案。
*Nicholas
应用程序:
最后是本示例中使用的 MyHGroup 组件。创建一个新的 MXML 文件名称 MyHGroup.mxml 并粘贴以下代码。
you did not post the data structure, i hope i got it right. The following demo creates and populates a TabNavigator with three NavigatorContent instances containing series of RadioButtons that can be selected using the method 'getHGroupById'.
I am sure it is possible to realize something like this using Bindable Data and ItemRenderes, probably the better solution.
*Nicholas
The Application:
Finally the MyHGroup Component used in this example. Create a new MXML File name MyHGroup.mxml and paste the following code.