初学者弹性问题:使用外部 MXML 和状态(以及调用父级函数)
Flex/FlashBuilder 相对较新,目前正在尝试制作 Android AIR 应用程序。我目前正在努力为每个页面使用外部 MXML 文件并通过调用 states 打开它们。
我计划的方法是调用 ButtonClicks 上的函数,该函数位于主 MXML 文件中。
问题是,我该如何调用这个函数呢?当我尝试使用:
<s:Button id="b1" label="Change to State 1" click="Main.goHome()'"/>
尽管这会引发错误。
这是首先采取的最佳方法吗?其次,如何访问主函数?从这个意义上来说,它与 ActionScript 似乎有些不同!
Relatively new to Flex/FlashBuilder and am currently trying to make an Android AIR app. I'm currently struggling to use external MXML files for each page and opening them by calling states.
The way I'm planning it is to call a function on buttonClicks which is housed in the main MXML file.
The thing is, how do I call this function? When I try using:
<s:Button id="b1" label="Change to State 1" click="Main.goHome()'"/>
Although this throws up an error.
Is this the best approach to take first of all? And second of all, how can I access the main function? It seems somewhat different to ActionScript in that sense!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下操作:
或
Try the following:
or
你可以试试Adnan的方法;不过,对于更一般的原则,我可能建议将 Main 的引用传递到您试图从中访问它的类中。
You could try Adnan's method; though for a more general principle I might suggest passing a reference of Main into the class you are trying to access it from.