mxml 中的静态/私有子组件?
有什么方法可以在 mxml 中声明私有/受保护甚至静态的子组件吗?
当然我们可以在脚本标签内执行此操作,但是还有其他方法吗?
Are there any way to declare a child component in mxml which is private/protected or even static?
Sure we can do this inside a script tag, but are there any other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Ashier 建议使用“排除”元数据标签,但 Maskit 提供了其局限性并建议了替代解决方案:
http://blog.ashier.com/2008/03/25/hiding-properties-in-flex-components/
http://smaskit.blogspot.com/2008/07/制作-mxml-subcomponent-private.html
Ashier suggests using the "Exclude" metadata tag, but Maskit offers its limitations and suggests alternative solutions:
http://blog.ashier.com/2008/03/25/hiding-properties-in-flex-components/
http://smaskit.blogspot.com/2008/07/making-mxml-subcomponent-private.html
从这些术语的严格含义来看,不,您不能使用 mxml 做到这一点。路易斯发布的第二个链接包含一些针对私有/受保护行为的解决方法。
In the strict meaning of these terms, no you can't do that using mxml. The second link posted by Luis contains some workarounds for private/protected behavior.
我找到了静态问题的解决方案。我想要一个快速记事本,可以在移动应用程序的任何位置访问,而无需一个实例覆盖在不同屏幕中打开的编辑内容。
我创建了一个记事本 mxml 控件,然后将其放置在顶级应用程序 mxml 的声明部分内。在我希望备忘录出现在的每个视图中,我添加了:
在视图创建完成中:
在 viewActivation 代码中,我添加了:
在 viewDeactivation 代码中,我添加了:
最终效果是只有一个备忘录实例存在于任何时间,并且一个实例以它在最后一次出现的视图中存在的任何状态打开。
I found a solution to the static question. I wanted a quick memo pad that could be accessed anywhere in the mobile app, without one instance overwriting edits left open in a different screen.
I created a memo pad mxml control, and then placed it inside a declarations section in the top level application mxml. In each view that I wanted the memo to appear in, I added:
In the view creation complete:
In the viewActivation code, I added:
In the viewDeactivation code, I included:
The net effect is that only one instance of the memo exists at any time, and that one instance opens in whatever state it existed in the last view it appeared in.