【问题标题】:Flex 3.5: Not able to retrieve the children of VBOX inside a tab navigatorFlex 3.5:无法在选项卡导航器中检索 VBOX 的子项
【发布时间】:2011-12-05 05:39:05
【问题描述】:

我在 tabNavigator 中有 2 个 VBox。

我感兴趣的VBox的sn-p代码如下

<mx:TabNavigator  id ="tabNav">

<mx:VBox label="Class Details" name="clsDetail" id="ClsDetails" height="301" width="300" >
       <mx:FormItem label="PropID"  name="PropoId" id="propoIDForm" direction="horizontal">
            <mx:NumericStepper id="propagatedIDInput" name ="objId"  minimum="0" maximum="100" stepSize="1" width="65"/>
       </mx:FormItem>

<mx:FormItem label="Difficulty" direction="horizontal">
                    <mx:RadioButtonGroup id="difficulty"/>
                    <mx:RadioButton label="Easy" groupName="difficulty" value="1"/>
                    <mx:RadioButton label="Medium" groupName="difficulty" value="2"/>
                    <mx:RadioButton label="Hard" groupName="difficulty" value="3"/>
          </mx:FormItem>

</mx:VBox>
</mx:TabNavigator>

我正在尝试设置数字步进器运行时,但我无法做到。尝试了2种方法

Approach 1: iterate through children and get the one

   var VBoxChildren:Array = ClsDetails.getChildren();
   for each(var currentFormItem:FormItem in VBoxChildren)
    {
     var FormChildren:Array = currentFormItem.getChildren(); //somehow it is becoming null
       for each(var currentItem:* in FormChildren) //doesn't go in since the array is null)
            {
              if(currentItem is NumericStepper)
                {
                 (currentItem as NumericStepper).value = int(markedObject.propagatedID);
                }
            }
      }

Approach 2: try to get children byname

  var myVBox:VBox = tabNav.getChildByName("clsDetail") as VBox;

   var frmItem:FormItem = myVBox.getChildByName("PropoId") as FormItem;//issue it becomes null ..somhownot able to get this children even though it is visible when I debug

    var  objId:NumericStepper = frmItem.getChildByName("objId") as NumericStepper; undefined as above is null

我不确定我在这里遗漏了什么...建议非常感谢!

Thanks
Akshay

【问题讨论】:

  • 你为什么要使用这么多编码?我不明白!你不能像propagatedIDInput.value=int(markedObject.propagatedID);那样在运行时直接赋值吗?
  • 实际上我一开始就是这样做的。但一直以来,由于延迟实例化未知,如果数字步进器没有被初始化,我没有得到参考……然后它让我震惊,我设置了 creationPolicy = all (这有点违背了目的),它就像一个魅力

标签: flex3 adobe


【解决方案1】:

我在 adobe 论坛上发布了我的问题,响应解决了它...实际上延迟实例化的问题不是在 tabnavigator 中设置我的子组件,而是设置 VBox(第一个子组件)...

我所缺少的只是设置creationPolicy = all(正如我上面的cmets所解释的)......它就像魅力一样......

这里有一篇很好的关于 PureMVC 的关于 Flex 组件的延迟实例化http://puremvc.org/content/view/91/188/

【讨论】:

    猜你喜欢
    • 2013-08-28
    • 2010-12-22
    • 2011-07-24
    • 2016-10-24
    • 2011-03-25
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 2020-03-28
    相关资源
    最近更新 更多