如何将参数从组件发送到主 MXML 应用程序
我想将变量或参数从组件发送到主(MXML)应用程序。就像我的组件是 FileUpload.mxml 一样,希望将上传的文件详细信息从 FileUpload.mxml 转发到 Main.mxml。
我尝试了以下过程:
com:FileUpload id="fp"
来获取 FileUpload 组件的引用,但是,我无法从 FileUpload.mxml 文件中获取变量。
谁能帮我解决这个问题?
宁静
I would like to send variables or parameters from Component to Main (MXML) Application. Like my component is FileUpload.mxml and would like to forward the uploaded file details from FileUpload.mxml to Main.mxml.
I tried the following procedure :
com:FileUpload id="fp"
to get the reference for the FileUpload component, however, I am unable to get the variables from the FileUpload.mxml file.
Can anyone help me to fix this issue ?
Serenity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您所处的开发阶段,您可能需要考虑一种肯定能帮助解决此类情况的 Flex 框架。我个人使用 Mate,但还有其他几个选项欧芹,Cairngorm, RobotLegs 等)。
使用 Mate,您可以创建一个自定义事件,该事件将在发生某些事情(例如上传文件)后调度。此自定义事件可以包含您想要传递给另一个组件的任何附加信息、属性或数据。然后,您可以将事件侦听器添加到您的自定义事件的主地图中。主地图将捕获您的自定义事件并重新路由到它需要前往的任何组件。
如果这不是一个选项,请确保您要访问的属性 a) 标记为
[Bindable]
和 b)public
。如果没有看到一些代码,很难说什么是最好的解决方案。Depending on what stage of development you're in you may want to consider one of the Flex frameworks out there that would definitely help with this type of situation. I personally use Mate, but there are several other options out there Parsley, Cairngorm, RobotLegs, etc.).
With Mate, you would create a custom event that would get dispatched after something happens (a file being uploaded for example). This custom event could include any additional information, properties or data you would like to pass to another component. You would then add an event listener to your main map for your custom event. The main map would capture your custom event and re-route to whichever component(s) it needed to go to.
If that's not an option, make sure the properties you want to access are a) marked as
[Bindable]
and b)public
. It's hard to say what could be the best solution without seeing some code.