获取动态生成的 Flex 组件的句柄
我有一个 Flex 应用程序,它引用一个单独的 MXML 文件作为自定义组件的模板。我在程序中多次动态创建该组件的实例,但我需要获得一个句柄,该句柄允许我根据需要修改该组件的实例。
我在实例化时使用组件的 MXML 文件中的可绑定公共变量将特定信息传递给该组件。我使用 addChild() 将其添加到我的主程序中。
我想根据需要更新组件的进度条,并且想将其从添加子项的框中删除。
获取变量的最简单/最好的方法是什么,该变量将使我能够对每个组件进行可预测的访问,以便我可以根据需要轻松地操作组件?一些研究表明创造已经完成,但我认为直接询问比进行大量不同的实验却一无所获更快。
感谢您的所有帮助。 :)
I have a Flex application which references a separate MXML file as a template for a custom component. I create instances of the component dynamically several times in my program, but I need to get a handle that will allow me to modify that instance of the component as desired.
I pass specific information to this component on instantiation using bindable public variables in the component's MXML file. I add it to my main program using addChild().
I want to update the component's progressbar as necessary and I want to remove it from the box to which I addChild'd it.
What's the easiest/best way to get a variable that will give me predictable access to each component so I can easily manipulate the components as necessary? Some research suggests creationComplete, but I decided it was faster to just ask than to go through lots of different experiments and come up blank.
Thanks for all the help. : )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能只将组件列表保存在数组中吗?当您创建它们并在其父级上调用 addChild() 时,大概您有一个对象引用。为什么不把它们同时放入一个数组中呢?
然后你就可以得到它们...
你必须确保完成后正确处理它们,因为数组中的引用将使它们保持存在直到清除。
如果您决定要使用 getChildren() 代替(您可以这样做),请花时间阅读文档,因为我认为它每次调用都会返回一个新数组。
我希望这有帮助。
Can you not just keep a list of your components in an array? Presumably you have an object reference when you create them and call addChild() on their parent. Why not just put them in an array at the same time?
then you can get at them...
You would have to make sure you dispose of them properly when you re done because the reference in your array would keep them in existence until cleared.
If you decide that you want to use getChildren() instead - which you could - take the time to read the documentation because I think it returns a new array with each call.
I hope that helps.