是否可以从Flex的子组件中调用父组件中的函数? [英] Is it possible to call a function in a parent component from a child component in Flex?

查看:97
本文介绍了是否可以从Flex的子组件中调用父组件中的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要调用位于父组件中的函数,并在Flex 3中从子组件进行调用.是否可以通过子组件访问父组件中的函数?我知道我可以在孩子中调度一个事件,并在父对象中添加一个侦听器来调用该函数,但只是想知道是否也可以直接从孩子中调用父函数.谢谢

I need to call a function located in the parent component and make the call from the child component in Flex 3. Is there a way to access functions in the parent component from the child component? I know I can dispatch an event in the child and add a listener in the parent to call the function, but just wanted to know if could also directly call a parent function from a child. Thanks

推荐答案

您可以使用parentApplication

You can use parentApplication

例如...如果我有一个main.mxml来调用组件,我们将其称为child.mxml,那么我可以通过执行以下操作从child内部调用main中的函数:

For example... if i have a main.mxml that calls a component we'll call child.mxml, i can call functions in main from within child by doing the following:

parentApplication.parentsFunctionName(parameters);

这篇关于是否可以从Flex的子组件中调用父组件中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆