Is it possible to call a function in a parent component from a child component in Flex?

南楼画角 提交于 2019-12-13 19:49:05

问题


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


回答1:


You can use parentApplication

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);


来源:https://stackoverflow.com/questions/3340516/is-it-possible-to-call-a-function-in-a-parent-component-from-a-child-component-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!