初学者弹性问题:使用外部 MXML 和状态(以及调用父级函数)

发布于 2024-10-07 20:29:47 字数 368 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

写给空气的情书 2024-10-14 20:29:47

尝试以下操作:

 click="parentApplication.goHome()"

 click="parentDocument.goHome()"

Try the following:

 click="parentApplication.goHome()"

or

 click="parentDocument.goHome()"
玩心态 2024-10-14 20:29:47

你可以试试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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文