动态创建状态的变化子级
我正在构建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扭转你的问题。不要尝试将信息推送到各州,让各州在需要时获取信息。
在每个状态中添加一个绑定来检查按钮的状态并执行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.
好吧,我一定要尝试一下你的建议。我用我的方式解决了这个问题,但我猜相当复杂:
创建状态时,我将每个 GridItem 推送到数组中,并创建一个返回数组的 getFunction,以便 Main.mxml 可以访问它。
Main.mxml 中的切换器函数如下所示:
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: