Is it possible to call a function in a parent comp

2019-08-11 05:12发布

问题:

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