动态创建状态的变化子级

发布于 2024-08-13 09:41:02 字数 293 浏览 2 评论 0原文

我正在构建一个 Xml 驱动的应用程序。 我在单独的动作脚本类中创建新状态。 这些状态都包含一个 DataGrid。 我可以在 Main.mxml 中切换状态。

但现在我想访问 DataGrid 的某些子项。在本例中,我想通过 Main.mxml 中的按钮切换 GridItems 的可见性。

我如何访问并将其应用于已创建的状态? 我尝试创建RemoveChilds 并将其覆盖/推送到状态。 我所实现的只是在最后一个状态下删除整个 GridRow,但在每个状态下它应该只有一个 GridItem。

非常感谢您的帮助!

I'm building an Xml-driven application.
I create new states in a seperate actionscript-class.
These states all contain a DataGrid.
I can switch the states in the Main.mxml.

But now I would like to access certain children of the DataGrid. In this case I would like to toggle the visibility of GridItems, from a Button in the Main.mxml.

How do I have access and apply this to the already created states ?
I tried to create RemoveChilds and override/push it to the state.
All I archieved was to remove an entire GridRow at the very last state, but it should be just one GridItem at every state.

Thanks a lot for help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

分分钟 2024-08-20 09:41:02

扭转你的问题。不要尝试将信息推送到各州,让各州在需要时获取信息。

在每个状态中添加一个绑定来检查按钮的状态并执行removeChild 逻辑本身。

Reverse your problem. Don't try push the information into the states, have the states fetch the information when needed.

Add a binding in each state to check the status of the button and do the removeChild logic itself.

不打扰别人 2024-08-20 09:41:02

好吧,我一定要尝试一下你的建议。我用我的方式解决了这个问题,但我猜相当复杂:
创建状态时,我将每个 GridItem 推送到数组中,并创建一个返回数组的 getFunction,以便 Main.mxml 可以访问它。
Main.mxml 中的切换器函数如下所示:

_gridItemArray = theStateClass.getGridItemArray();

if(_buttonToggler == false)
{
      for each(_gridItemArray.child in _gridItemArray)
  {
    _gridItemArray.child.visible = false;
  }
 _buttonToggler = true;
}

else
{
   for each(_gridItemArray.child in _gridItemArray)
   {
      _gridItemArray.child.visible = true;
   }
       _buttonToggler = false;
    }

Ok, I definitively have to try your suggestions. I worked it out in my way, but rather complicated I guess:
I push every GridItem in an array when the states are created and create a getFunction which returns the array and so the Main.mxml can access it.
The toggler-function in the Main.mxml looks like this:

_gridItemArray = theStateClass.getGridItemArray();

if(_buttonToggler == false)
{
      for each(_gridItemArray.child in _gridItemArray)
  {
    _gridItemArray.child.visible = false;
  }
 _buttonToggler = true;
}

else
{
   for each(_gridItemArray.child in _gridItemArray)
   {
      _gridItemArray.child.visible = true;
   }
       _buttonToggler = false;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文